Very similar questions out already but I haven't been able to find one that really matches what I have going on.
This is a facial recognition app with about 200 lines of code so I will just post the part that is relevant.
The app does face recognition and then displays a the target photo next to the best matched mugshot. In case of false positives it also shows a list of the best 5 matches.
I would like for the images in this list to open upon running the code, however only one image in the list is opening for whatever reason.
Relevant piece of code:
# set distance between known faces and target face. The lower the distance between them the lower the match. Higher dist = more error.
if face_distances[best_match_index] < 0.60:
name = known_face_names[best_match_index]
resulttolog = "Match found within default tolerance level. " + "\n" "Match identified as: " + name + "\n"
log(resulttolog) # logging result
# save and display mugshot of best match
mugshot = cv2.imread(os.getcwd() + "/datasets/" + name + ".jpg")
mugshotresized = cv2.resize(mugshot, (500, 500), fx=0.5, fy=0.5)
cv2.imwrite(os.getcwd() + "/mugshot.jpg", mugshotresized)
# listing other closest maches
best_5_matches = n_known_face_names[top_3_matches]
matchestolist = list(best_5_matches)
log("Best matches in order:")
# sort list by number
for index, mugshot in enumerate(matchestolist, 1):
log("{}. {}".format(index, mugshot)) # log the numbered list
# pop up relevant matches
for filename in matchestolist:
path = os.getcwd() + "/datasets/"
file = path + filename + ".jpg"
img = cv2.imread(file)
cv2.imshow("image", img)
So in this last part, the images are supposed to all open. (i assume one pop up window for each image since its a for loop, but only one window is popping up with the first image).
Seems like an easy solution but I cant figure it out..
Any ideas?