MSFaceAPI.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:SOLAMS 作者: aishmittal 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号