一、百度API
官网:http://ai.baidu.com/tech/face
官方文档:http://ai.baidu.com/docs#/Face-Detect-V3/top
过程:1、创建应用;2、编写程序;3、调用API。
二、人脸识别
# 官方文档 http://ai.baidu.com/docs#/Face-Python-SDK/3d1dd00c
from aip import AipFace
import base64
'''创建应用'''
APP_ID = ''
API_KEY = ''
SECRET_KEY = ''
client=AipFace(APP_ID,API_KEY,SECRET_KEY)
"""
'''注册'''
'''人脸检测图片参数传入'''
filepath='./image/anglebaby_1.jpg'
with open(filepath,'rb') as f:
base64_data=base64.b64encode(f.read())
image =str(base64_data,'utf-8')
imageType='BASE64'
groupId = "group1"
userId = "anglebaby"
''' 调用人脸注册 '''
result=client.addUser(image, imageType, groupId, userId);
print(result)
"""
'''调用人脸搜索'''
filepath='./image/anglebaby_2.jpg'
with open(filepath,'rb') as f:
base64_data=base64.b64encode(f.read())
image =str(base64_data,'utf-8')
imageType = "BASE64"
groupIdList = "group1"
'''搜索'''
result=client.search(image, imageType, groupIdList)
print(result)