2、人脸识别

from aip import AipFace
import base64

""" 你的 APPID AK SK """
APP_ID = '25391663'
API_KEY = 'kodIL2oajI05IouwuMHLYQ95'
SECRET_KEY = 'plLURW14jPMamOw3i3TUO6UB7Sfq874C'

face_client = AipFace(APP_ID, API_KEY, SECRET_KEY)

""" 读取图片 """


def get_file_content(filePath):
    with open(filePath, 'rb') as fp:
        return fp.read()



bytes_str=base64.b64encode(get_file_content('5.jpg'))
image = str(bytes_str,"utf8")

imageType = "BASE64"

""" 调用人脸检测 """
res = face_client.detect(image, imageType);

""" 如果有可选参数 """
options = {}
options["face_field"] = "age"
options["max_face_num"] = 2
options["face_type"] = "LIVE"
options["liveness_control"] = "LOW"

print(res)

posted @ 2023-02-09 02:16  Jackiezhu  阅读(35)  评论(0)    收藏  举报