欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-06-15 19:44:16
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