def face_detect(image_url):
params =urllib.urlencode({
# Request parameters
'returnFaceId': 'true',
'returnFaceLandmarks': 'false'
})
body = '{"url":"%s"}'% image_url
try:
conn = httplib.HTTPSConnection('westus.api.cognitive.microsoft.com')
conn.request("POST", "/face/v1.0/detect?%s" % params, body, headers)
response = conn.getresponse()
data = response.read()
conn.close()
obj = json.loads(data)
#print obj[0]['faceId']
return obj[0]['faceId']
except Exception as e:
print("Error: %s" % e.message)
评论列表
文章目录