import cv2
import numpy as np
import face_recognition

# Load and encode images
imgElon = face_recognition.load_image_file('ImageBasic/Elon Musk.jpg')
imgElon = cv2.cvtColor(imgElon, cv2.COLOR_BGR2RGB)
imgTest = face_recognition.load_image_file('ImageBasic/elon musky test.jpg')
imgTest = cv2.cvtColor(imgTest, cv2.COLOR_BGR2RGB)

imgMads = face_recognition.load_image_file('ImageAttendance/Mads Mikkelsen.jpg')
imgMads = cv2.cvtColor(imgMads, cv2.COLOR_BGR2RGB)

# place square around detected face
faceLoc = face_recognition.face_locations(imgElon)[0]
encodeElon = face_recognition.face_encodings(imgElon)[0]
#print(faceLoc)
cv2.rectangle(imgElon, (faceLoc[3], faceLoc[0]), (faceLoc[1], faceLoc[2]), (255, 0, 230), 3)

faceLocTest = face_recognition.face_locations(imgTest)[0]
encodeTest = face_recognition.face_encodings(imgTest)[0]
cv2.rectangle(imgTest, (faceLocTest[3], faceLocTest[0]), (faceLocTest[1], faceLocTest[2]), (255, 0, 230), 3)

# compare
results = face_recognition.compare_faces([encodeElon], encodeTest)
faceDis = face_recognition.face_distance([encodeElon], encodeTest)
print(results, faceDis)
cv2.putText(imgTest, f'{results} {round(faceDis[0], 2)}', (50, 50), cv2.FONT_HERSHEY_DUPLEX, 1, (0, 0, 255), 2)

cv2.imshow('Elon Muskrat', imgElon)
cv2.imshow('Elon Test', imgTest)
cv2.waitKey(0)
bc444d42940bbf2070916b9ca8db688910c98086
<mask token>

<mask token>
cv2.rectangle(imgElon, (faceLoc[3], faceLoc[0]), (faceLoc[1], faceLoc[2]),
    (255, 0, 230), 3)
<mask token>
cv2.rectangle(imgTest, (faceLocTest[3], faceLocTest[0]), (faceLocTest[1],
    faceLocTest[2]), (255, 0, 230), 3)
<mask token>
print(results, faceDis)
cv2.putText(imgTest, f'{results} {round(faceDis[0], 2)}', (50, 50), cv2.
    FONT_HERSHEY_DUPLEX, 1, (0, 0, 255), 2)
cv2.imshow('Elon Muskrat', imgElon)
cv2.imshow('Elon Test', imgTest)
cv2.waitKey(0)

<mask token>
imgElon = face_recognition.load_image_file('ImageBasic/Elon Musk.jpg')
imgElon = cv2.cvtColor(imgElon, cv2.COLOR_BGR2RGB)
imgTest = face_recognition.load_image_file('ImageBasic/elon musky test.jpg')
imgTest = cv2.cvtColor(imgTest, cv2.COLOR_BGR2RGB)
imgMads = face_recognition.load_image_file('ImageAttendance/Mads Mikkelsen.jpg'
    )
imgMads = cv2.cvtColor(imgMads, cv2.COLOR_BGR2RGB)
faceLoc = face_recognition.face_locations(imgElon)[0]
encodeElon = face_recognition.face_encodings(imgElon)[0]
cv2.rectangle(imgElon, (faceLoc[3], faceLoc[0]), (faceLoc[1], faceLoc[2]),
    (255, 0, 230), 3)
faceLocTest = face_recognition.face_locations(imgTest)[0]
encodeTest = face_recognition.face_encodings(imgTest)[0]
cv2.rectangle(imgTest, (faceLocTest[3], faceLocTest[0]), (faceLocTest[1],
    faceLocTest[2]), (255, 0, 230), 3)
results = face_recognition.compare_faces([encodeElon], encodeTest)
faceDis = face_recognition.face_distance([encodeElon], encodeTest)
print(results, faceDis)
cv2.putText(imgTest, f'{results} {round(faceDis[0], 2)}', (50, 50), cv2.
    FONT_HERSHEY_DUPLEX, 1, (0, 0, 255), 2)
cv2.imshow('Elon Muskrat', imgElon)
cv2.imshow('Elon Test', imgTest)
cv2.waitKey(0)

import cv2
import numpy as np
import face_recognition
imgElon = face_recognition.load_image_file('ImageBasic/Elon Musk.jpg')
imgElon = cv2.cvtColor(imgElon, cv2.COLOR_BGR2RGB)
imgTest = face_recognition.load_image_file('ImageBasic/elon musky test.jpg')
imgTest = cv2.cvtColor(imgTest, cv2.COLOR_BGR2RGB)
imgMads = face_recognition.load_image_file('ImageAttendance/Mads Mikkelsen.jpg'
    )
imgMads = cv2.cvtColor(imgMads, cv2.COLOR_BGR2RGB)
faceLoc = face_recognition.face_locations(imgElon)[0]
encodeElon = face_recognition.face_encodings(imgElon)[0]
cv2.rectangle(imgElon, (faceLoc[3], faceLoc[0]), (faceLoc[1], faceLoc[2]),
    (255, 0, 230), 3)
faceLocTest = face_recognition.face_locations(imgTest)[0]
encodeTest = face_recognition.face_encodings(imgTest)[0]
cv2.rectangle(imgTest, (faceLocTest[3], faceLocTest[0]), (faceLocTest[1],
    faceLocTest[2]), (255, 0, 230), 3)
results = face_recognition.compare_faces([encodeElon], encodeTest)
faceDis = face_recognition.face_distance([encodeElon], encodeTest)
print(results, faceDis)
cv2.putText(imgTest, f'{results} {round(faceDis[0], 2)}', (50, 50), cv2.
    FONT_HERSHEY_DUPLEX, 1, (0, 0, 255), 2)
cv2.imshow('Elon Muskrat', imgElon)
cv2.imshow('Elon Test', imgTest)
cv2.waitKey(0)

import cv2
import numpy as np
import face_recognition

# Load and encode images
imgElon = face_recognition.load_image_file('ImageBasic/Elon Musk.jpg')
imgElon = cv2.cvtColor(imgElon, cv2.COLOR_BGR2RGB)
imgTest = face_recognition.load_image_file('ImageBasic/elon musky test.jpg')
imgTest = cv2.cvtColor(imgTest, cv2.COLOR_BGR2RGB)

imgMads = face_recognition.load_image_file('ImageAttendance/Mads Mikkelsen.jpg')
imgMads = cv2.cvtColor(imgMads, cv2.COLOR_BGR2RGB)

# place square around detected face
faceLoc = face_recognition.face_locations(imgElon)[0]
encodeElon = face_recognition.face_encodings(imgElon)[0]
#print(faceLoc)
cv2.rectangle(imgElon, (faceLoc[3], faceLoc[0]), (faceLoc[1], faceLoc[2]), (255, 0, 230), 3)

faceLocTest = face_recognition.face_locations(imgTest)[0]
encodeTest = face_recognition.face_encodings(imgTest)[0]
cv2.rectangle(imgTest, (faceLocTest[3], faceLocTest[0]), (faceLocTest[1], faceLocTest[2]), (255, 0, 230), 3)

# compare
results = face_recognition.compare_faces([encodeElon], encodeTest)
faceDis = face_recognition.face_distance([encodeElon], encodeTest)
print(results, faceDis)
cv2.putText(imgTest, f'{results} {round(faceDis[0], 2)}', (50, 50), cv2.FONT_HERSHEY_DUPLEX, 1, (0, 0, 255), 2)

cv2.imshow('Elon Muskrat', imgElon)
cv2.imshow('Elon Test', imgTest)
cv2.waitKey(0)