python使用百度ai人脸检测,应该是图片编码有问题,总是返回错误'error_code': 222203, 'error_msg': 'image check fail'
官方sdk3文档说,图片需要base64数据进行urlencode,但是不行啊from client import client
import base64
import urllib.parse
with open("2.jpg","rb") as f:
base64_image = base64.b64encode(f.read())
base64_data = urllib.parse.quote(base64_image)
image = base64_data # "取决于image_type参数,传入BASE64字符串或URL字符串或FACE_TOKEN字符串"
imageType = "BASE64"
if __name__ == "__main__":
face_feature = client.detect(image,imageType)
print(face_feature)
如果不使用urllib.parse.quote 报错TypeError: Object of type bytes is not JSON serializable
现在是返回'error_code': 222203, 'error_msg': 'image check fail'