|
@@ -35,7 +35,7 @@ def find_faces_in_images(image_dir, known_face_encodings, known_face_names):
|
|
|
|
|
|
found_faces = []
|
|
|
for face_encoding in face_encodings:
|
|
|
- matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
|
|
|
+ matches = face_recognition.compare_faces(known_face_encodings, face_encoding, tolerance=0.35)
|
|
|
name = "Unknown"
|
|
|
|
|
|
if True in matches:
|
|
@@ -46,6 +46,8 @@ def find_faces_in_images(image_dir, known_face_encodings, known_face_names):
|
|
|
|
|
|
if found_faces:
|
|
|
results[filename] = found_faces
|
|
|
+ else:
|
|
|
+ results[filename] = None
|
|
|
|
|
|
return results
|
|
|
|
|
@@ -57,7 +59,10 @@ def main():
|
|
|
results = find_faces_in_images(image_dir, known_face_encodings, known_face_names)
|
|
|
|
|
|
for image_name, found_faces in results.items():
|
|
|
- print(f"In {image_name}, found faces: {', '.join(found_faces)}")
|
|
|
+ if not found_faces:
|
|
|
+ print(f"In {image_name}, no faces detected")
|
|
|
+ else:
|
|
|
+ print(f"In {image_name}, found faces: {', '.join(found_faces)}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
main()
|