当前位置: 移动技术网 > IT编程>开发语言>JavaScript > 旷视face++实现实时人脸识别比对

旷视face++实现实时人脸识别比对

2020年07月12日  | 移动技术网IT编程  | 我要评论
opencv开启前置摄像头拍照,与原有图片比较相似度# coding:utf-8import requestsfrom json import JSONDecoderimport cv2compare_url = "https://api-cn.faceplusplus.com/facepp/v3/compare"key = ""secret = ""faceId1 = "../1.jpg"cap = cv2.VideoCapture(0)ret, frame = cap.read()

opencv开启前置摄像头拍照,与原有图片比较相似度

# coding:utf-8
import requests
from json import JSONDecoder
import cv2
compare_url = "https://api-cn.faceplusplus.com/facepp/v3/compare"
key = ""
secret = ""
faceId1 = "../1.jpg"
cap = cv2.VideoCapture(0)
ret, frame = cap.read()
cv2.imwrite("../3.jpg", frame)
faceId2 = "../3.jpg"

data = {"api_key": key, "api_secret": secret}
files = {"image_file1": open(faceId1, "rb"), "image_file2": open(faceId2, "rb")}
response = requests.post(compare_url, data=data, files=files)

req_con = response.content.decode('utf-8')
req_dict = JSONDecoder().decode(req_con)

confindence = req_dict.get('confidence')
print("相似度为:",confindence)
if confindence>=80:
    print("数据比对成功,这两个人是同一个人,他们的相似度为%s"%confindence)
elif confindence>=70:
    print("相似度为%s不确定是不是同一个人"%confindence)
else:
    print("相似度为%s,两个人不是同一个人"%confindence)



本文地址:https://blog.csdn.net/weixin_43476533/article/details/107245385

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网