Я также пытался выяснить, как можно добавить новые кодировки лиц без получения ложных срабатываний. На данный момент у меня нет решения, и мне интересно, сталкивался ли кто-нибудь с этой проблемой или может дать какие-либо рекомендации.
Код: Выделить всё
import face_recognition
import cv2
import numpy as np
known_face_encodings = []
video_capture = cv2.VideoCapture(0)
while True:
ret, frame = video_capture.read()
# Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses)
rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
# Find all the faces and their encodings in the current frame
face_locations = face_recognition.face_locations(rgb_frame)
face_encodings = face_recognition.face_encodings(rgb_frame, face_locations)
for face_encoding in face_encodings:
matches = face_recognition.compare_faces(
known_face_encodings, face_encoding)
if True in matches:
# Get the index of the first True match
first_match_index = matches.index(True)
# Retrieve the matched face encoding from the known_face_encodings list
matched_face_encoding = known_face_encodings[first_match_index]
else:
# Add unkown face encoding
known_face_encodings.append(face_encoding)
Подробнее здесь: https://stackoverflow.com/questions/792 ... -new-faces
Мобильная версия