在文件夹logi中复制图像

2024-04-26 06:28:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在试图找到文件夹中重复图像的计数。我想打印唯一的图像与计数(多少重复它有)。我该怎么做? 我现在的代码:

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

Tags: pathin图像imageforifresultcv2
1条回答
网友
1楼 · 发布于 2024-04-26 06:28:59

您可以使用散列来检查文件是否已经在该目录中。你知道吗

为每个文件生成一个散列,将其写入数组/数据库,并检查每个文件的散列是否已在该目录中-如果已存在,请删除它/count+=1。你知道吗

此外:

https://github.com/philipbl/duplicate-images

相关问题 更多 >