我正在试图找到文件夹中重复图像的计数。我想打印唯一的图像与计数(多少重复它有)。我该怎么做? 我现在的代码:
for i in image_path_list:
image2 = cv2.imread(i)
image2 = cv2.resize(image2,(360,480))
for j in image_path_list:
if i!=j:
image1=cv2.imread(j)
image1=cv2.resize(image1, (360,480))
difference = cv2.subtract(image1, image2)
result = not np.any(difference) #if difference is all zeros it will return False
if result is True:
print(i)
else:
continue
您可以使用散列来检查文件是否已经在该目录中。你知道吗
为每个文件生成一个散列,将其写入数组/数据库,并检查每个文件的散列是否已在该目录中-如果已存在,请删除它/count+=1。你知道吗
此外:
相关问题 更多 >
编程相关推荐