【百度人脸识别】》人脸检测接口调用
程序员文章站
2022-07-12 18:40:15
...
相关文档
https://cloud.baidu.com/doc/FACE/s/yk37c1u4t
接口详细相关参数请参考开发文档
代码:
import base64
import json
import requests
from flask import Flask, jsonify
from constants import API_Key, Secret_Key
app = Flask(__name__)
@app.route('/face_detection')
def detection():
Access_Token = None
# 获取调用接口所需的AccessToken
host = f'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id={API_Key}&client_secret={Secret_Key}'
response = requests.get(host)
if response:
# print(response.json())
Access_Token = response.json().get('access_token')
print(Access_Token)
# 进行人脸检测调用接口
with open("903.jpg", "rb") as f:
# b64encode:编码,b64decode: 解码
base64_903 = base64.b64encode(f.read())
headers = {'content-type': 'application/json'}
payload = json.dumps(
{
'image': str(base64_903, 'utf-8'),
'image_type': 'BASE64',
}
)
URL = 'https://aip.baidubce.com/rest/2.0/face/v3/detect' + "?access_token=" + Access_Token
resp = requests.post(URL, data=payload, headers=headers)
if resp:
print(resp.json())
return jsonify(resp.json())
return jsonify('出错了!!!')
if __name__ == '__main__':
app.run()
返回结果:
人脸对比接口调用代码相关链接:
https://blog.csdn.net/h18208975507/article/details/109000613
上一篇: Nginx 反向代理设置
推荐阅读
-
人脸检测识别opencv+python实现(Haar分类器)
-
AI+人脸识别硬件,百度为180万开发者定制了“新武器”
-
C# 10分钟完成百度人脸识别——入门篇
-
Html5调用手机摄像头并实现人脸识别的实现
-
基于jupyter notebook的python编程(Win10通过OpenCv-3.4.1进行人脸口罩数据集的模型训练并进行戴口罩识别检测)
-
利用face_recognition,dlib与OpenCV调用摄像头进行人脸识别
-
基于C# 调用百度AI 人脸识别
-
PHP实现百度人脸识别
-
Python人脸识别第三方库face_recognition接口说明文档
-
Linkface人脸检测识别:四位女创始人,号称检测算法世界第一