# -*- 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 的參數(shù),但我無法這樣做。我想改變代碼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) 因為我想添加更多參數(shù),以便我獲得的信息豐富。我該怎么做呢?現(xiàn)在我只得到人臉和 face_token 的坐標。
添加回答
舉報
0/150
提交
取消