Esempio n. 1
0
def main():
    capture_images()
    aligned = facenet.align_face(images)
    comparisons = facenet.compare(aligned)

    print("Is image 1 and 2 similar? ", bool(comparisons[0][1]))
    print("Is image 1 and 3 similar? ", bool(comparisons[0][2]))
Esempio n. 2
0
from easyfacenet.simple import facenet
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
images = [
    'images/adi.jpeg', 'images/state.jpeg', 'images/state2.jpeg',
    'images/erik.jpeg', 'images/state3.jpeg'
]
aligned = facenet.align_face(images)
comparisons = facenet.compare(aligned)

print("Is image ADI and ERIK similar? ", bool(comparisons[0][3]))
print("Is image STATE and ERIK similar? ", bool(comparisons[1][3]))
print("Is image STATE and STATE2 similar? ", bool(comparisons[1][2]))
print("Is image STATE and STATE3 similar? ", bool(comparisons[1][4]))
    'haarcascades/haarcascade_frontalface_default.xml')
eye_cascade = cv.CascadeClassifier('haarcascades/haarcascade_eye.xml')
name = ["Adan", "Erick", "Python", "Geras"]

cap = cv.VideoCapture(0)
while True:
    _, frame = cap.read()
    gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
    faces = face_cascade.detectMultiScale(gray, 1.3, 5)
    for (x, y, w, h) in faces:
        cv.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
        face = frame[y - 10:y + h + 10, x - 10:x + w + 10]
        cv.imwrite("images/face.jpg", face)

    if cv.waitKey(1) & 0xFF == ord('q'):
        for i in range(4):
            nombre = "images/" + str(name[i]) + ".jpeg"
            images = ["images/face.jpg", nombre]
            aligned = facenet.align_face(images)
            comparar = facenet.compare(aligned)
            if bool(comparar[0][1]):
                print(name[i])
                break
    cv.imshow('frame', frame)
    if cv.waitKey(10) == 27:
        break
cap.release()
cv.destroyAllWindows()

np.load = np_load_old