import glob import cv2 as cv import numpy as np def nn1(listoffnames, dist='L1'): # your function here, and return correct things # this is a placeholder to get my code to run return (listoffnames[0],listoffnames[1]) filelist = glob.glob('example-images/*.jpg') # change to 'example-images\\*.jpg' on Windows print(filelist) listoflists = [] for i in range(len(filelist)): #print(filelist[0]) listoflists.append(filelist.copy()) # make a copy of the list of names and append it save = filelist[0] filelist.remove(filelist[0]) filelist.append(save) # these 3 lines move the first file name to the end # which makes the list have a different first element print(listoflists) # listoflists now contains n versions of the filelist with # a different file name as the first element (to act as the key) for i in range(len(listoflists)): #debug code to make sure the lists really had a different first element #print("list", i) #for j in range(len(listoflists[i])): # print(listoflists[i][j]) keyimgname, matchimgname = nn1(listoflists[i], 'L1') keyimg = cv.imread(keyimgname) matchimg = cv.imread(matchimgname) cv.imshow('key image', keyimg) cv.imshow('match image', matchimg) cv.waitKey(0) cv.destroyAllWindows()