def get_best_n(img_path, db_dir,n=10,types = ('*.jpg','*.tif','*.png')): os.chdir(db_dir) files_grabbed = [] for files in types: files_grabbed.extend(glob.glob(files)) hist_list=[] for names in files_grabbed: full_path= db_dir+'\\'+names src = cv.LoadImage(full_path, cv.CV_LOAD_IMAGE_COLOR) hist_list.append(compute_histogram_rgb(src)) score_list=[] img= cv.LoadImage(img_path, cv.CV_LOAD_IMAGE_COLOR) hist= compute_histogram_rgb(img) for h in hist_list: score_list.append(cv.CompareHist(hist, h, cv.CV_COMP_CORREL)) score_list.sort() return score_list
мне необходимо как то вместе соединить имена изображений из files_grabbed и score_list, т.е. получиться список структур(?), а потом отсортировать по score_list и взять первые n и вывести их имена.