python 模板匹配图像聚类

x33g5p2x  于2021-11-14 转载在 Python  
字(0.6k)|赞(0)|评价(0)|浏览(276)
import glob
import shutil

from natsort import natsorted

if __name__ == '__main__':

    # path=r'C:/2021-11\images-optional\48'
    # files = glob.glob(path + "/*/*.jpg")
    # print(len(files))
    # exit(1)
    import cv2
    import os
    import numpy as np

    path = r"C:/2021-11\images-optional/"

    files=glob.glob(path+"*.jpg")

    files=natsorted(files)
    dir_dict={}
    exclude=[]
    for index, file in enumerate(files):
        if index in exclude:
            continue
        template = cv2.imread(file, 0)
        temp_h,temp_w= template.shape[:2]
        for i in range(index-30,index+30):
            if i<0 or i>=len(files)-1:
                continue
            target = cv2.imread(files[i], 0)
            if target is None:
                continue

            t_h, t_w = target.shape[:2]
            thread &#

相关文章