У меня есть следующий код:
import face_recognition
from PIL import Image, ImageDraw
from tkinter import Tk
from tkinter.filedialog import askopenfilename
from shutil import copyfile
#Ask user for file name
Tk().withdraw()
filename = askopenfilename()
#Add known images
image_of_person = face_recognition.load_image_file(filename)
person_face_encoding = face_recognition.face_encodings(image_of_person)[0]
for i in range (1, 8):
#Construct the picture name and print it
file_name = str(i).zfill(5) + ".jpg"
print(file_name)
#Load the file
newPic = face_recognition.load_image_file(file_name)
#Search every detected face
for face_encoding in face_recognition.face_encodings(newPic):
results = face_recognition.compare_faces([person_face_encoding], face_encoding, 0.5)
#If match, show it
if results[0] == True:
copyFile(file_name, "./img/saved" + file_name)
Намерение - использовать известное изображение (image_of_person) и искать в папке изображений ('./img/unknown') совпадение. , затем показать совпавшее фото.
Я получаю сообщение об ошибке:
No such file or directory: '00001.jpg'
На линии
newPic = face_recognition.load_image_file(file_name)
Как мне указать распознавание в папке образцов изображений?
Примечание: for i in range (1, 8):
- 8 Изображения находятся в папке образцов.