为了账号安全,请及时绑定邮箱和手机立即绑定

Face Plus Plus Python API 更改参数

Face Plus Plus Python API 更改参数

繁华开满天机 2021-06-11 14:13:42
# -*- coding: utf-8 -*-import urllib2import urllibimport timehttp_url = 'https://api-us.faceplusplus.com/facepp/v3/detect'key = ""secret = ""filepath = r"iop.jpg"boundary = '----------%s' % hex(int(time.time() * 1000))data = []data.append('--%s' % boundary)data.append('Content-Disposition: form-data; name="%s"\r\n' % 'api_key')data.append(key)data.append('--%s' % boundary)data.append('Content-Disposition: form-data; name="%s"\r\n' % 'api_secret')data.append(secret)data.append('--%s' % boundary)fr=open(filepath,'rb')data.append('Content-Disposition: form-data; name="%s"; filename="co33.jpg"' % 'image_file')data.append('Content-Type: %s\r\n' % 'application/octet-stream')data.append(fr.read())fr.close()data.append('--%s--\r\n' % boundary)http_body='\r\n'.join(data)#buld http requestreq=urllib2.Request(http_url)#headerreq.add_header('Content-Type', 'multipart/form-data; boundary=%s' % boundary)req.add_data(http_body)try:    #post data to server    resp = urllib2.urlopen(req, timeout=5)    #get response    qrcont=resp.read()    print qrcontexcept urllib2.HTTPError as e:    print e.read()我正在尝试更改人脸识别 API 的参数,但我无法这样做。我想改变代码def detect_image(img_path):    endpoint = 'https://api-us.faceplusplus.com'    img_file = base64.encodestring(open(img_path, 'rb').read())    try:        response = requests.post(            endpoint + '/facepp/v3/detect',            {                'api_key': API_KEY,                'api_secret': API_SECRET,                # 'image_url': img_url,                'image_base64': img_file,                'return_landmark': 1,                'return_attributes': 'headpose,eyestatus,facequality,mouthstatus,eyegaze'            }        )        # 5秒スリープ        time.sleep(5) 因为我想添加更多参数,以便我获得的信息丰富。我该怎么做呢?现在我只得到人脸和 face_token 的坐标。
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 113 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信