基于百度云管理平台的人脸比对登录

3791.1973 2019-05-16 11:11:56
def login_faceCheck(request):
cap = cv2.VideoCapture(0) # 调整参数实现读取视频或调用摄像头

while 1:
ret, frame = cap.read()
cv2.imwrite("face.png", frame)
cv2.imshow("cap", frame)
if cv2.waitKey(100) & cv2.waitKey(0):
# if cv2.waitKey(100) & 0xff == ord('q'):
break

cap.release()
cv2.destroyAllWindows()

APP_ID = ' '
API_KEY = ' '
SECRET_KEY = ' '
client = AipFace(APP_ID, API_KEY, SECRET_KEY)

options = {}
options["quality_control"] = "NORMAL"
options["liveness_control"] = "LOW"
options["user_id"] = " "
options["max_user_num"] = 3

imageType = 'BASE64'
groupIdList = " "

def getImage(imagepath):
with open(imagepath, 'rb') as file:
image = file.read()
image = base64.b64encode(image)
image = str(image, encoding='utf-8')
return image
pass

image = getImage(' .png')

jsonResult = client.search(getImage('face.png'), imageType, groupIdList)

if jsonResult:
print(jsonResult)
jsonString = jsonResult["result"]
newjsonResult = jsonString["user_list"]
centerDirt = newjsonResult[0]
finalResult = centerDirt["score"]

if finalResult >= 80:
return render(request, 'index.html')
else:
return render(request, 'un_login.html')
pass
...全文
128 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
blog_1103 2019-05-23
  • 打赏
  • 举报
回复
你想问什么,

3,423

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 其他开发语言
社区管理员
  • 其他开发语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧