打开简历比较两个人脸嵌入

Ksh*_*war 3 opencv face-recognition python-3.x

我完成了Pyimagesearch 人脸识别教程,但我的应用程序只需要比较两个人脸,我嵌入了两个人脸,如何使用 opencv 比较它们?关于用于从面部提取嵌入的训练模型在链接中提到,我想知道我应该尝试比较两个面部嵌入的方法。

(注:我是这个领域的新手)

Aks*_*kar 5

首先,您的情况与给定的教程类似,您需要与测试图像进​​行比较,而不是多个图像,

所以你真的不需要这里的训练步骤。

你可以做

# read 1st image and store encodings
image = cv2.imread(args["image"])
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

boxes = face_recognition.face_locations(rgb, model=args["detection_method"])
encodings1 = face_recognition.face_encodings(rgb, boxes)

# read 2nd image and store encodings
image = cv2.imread(args["image"])
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

boxes = face_recognition.face_locations(rgb, model=args["detection_method"])
encodings2 = face_recognition.face_encodings(rgb, boxes)


# now you can compare two encodings
# optionally you can pass threshold, by default it is 0.6
matches = face_recognition.compare_faces(encoding1, encoding2)
Run Code Online (Sandbox Code Playgroud)

matches会给你TrueFalse根据你的图像

  • 在转向其他模型之前,请尝试使用“compare_faces”中的“tolerance”。您需要为您的案例找到最佳价值。默认值为“0.6”。尝试将其更改为“0.5”或更少 (2认同)