Ksh*_*war 3 opencv face-recognition python-3.x
我完成了Pyimagesearch 人脸识别教程,但我的应用程序只需要比较两个人脸,我嵌入了两个人脸,如何使用 opencv 比较它们?关于用于从面部提取嵌入的训练模型在链接中提到,我想知道我应该尝试比较两个面部嵌入的方法。
(注:我是这个领域的新手)
首先,您的情况与给定的教程类似,您需要与测试图像进行比较,而不是多个图像,
所以你真的不需要这里的训练步骤。
你可以做
# 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会给你True或False根据你的图像
| 归档时间: |
|
| 查看次数: |
10233 次 |
| 最近记录: |