import os
import sys
import face_recognition

# Get the images to compare
images = os.listdir('photos')

# load the image to match
image_to_be_matched = face_recognition.load_image_file(sys.argv[1])

# Convert the image into a feature vector
image_to_be_matched_encoded = face_recognition.face_encodings(image_to_be_matched)[0]

# Loop through the images comparing each
for image in images:
    current_image = face_recognition.load_image_file("photos/" + image)
    current_image_encoded = face_recognition.face_encodings(current_image)[0]
    result = face_recognition.compare_faces(
        [image_to_be_matched_encoded], current_image_encoded)

    if result[0] == True:
        print("Matched the image: " + image)
    else:
        print("Did not match the image: " + image)