这用于人脸识别的算法是什么?

2024-09-25 00:32:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在寻找面部识别的代码,但我需要知道使用了什么算法。 它使用OpenCV和人脸识别。有没有办法从中分辨出使用的算法

 # face recognition
    faces_cur_frame = face_recognition.face_locations(frame)
    encodes_cur_frame = face_recognition.face_encodings(frame, faces_cur_frame)
    # count = 0
    for encodeFace, faceLoc in zip(encodes_cur_frame, faces_cur_frame):
        match = face_recognition.compare_faces(encode_list_known, encodeFace, tolerance=0.50)
        face_dis = face_recognition.face_distance(encode_list_known, encodeFace)
        name = "unknown"
        best_match_index = np.argmin(face_dis)
        # print("s",best_match_index)
        if match[best_match_index]:
            name = class_names[best_match_index].upper()
            y1, x2, y2, x1 = faceLoc
            cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
            cv2.rectangle(frame, (x1, y2 - 20), (x2, y2), (0, 255, 0), cv2.FILLED)
            cv2.putText(frame, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 0.5, (255, 255, 255), 1)
        mark_attendance(name)

    return frame

Tags: name算法indexmatchcv2framefacebest