【问题标题】:Microsoft Face Api verify for pythonMicrosoft Face Api 验证 python
【发布时间】:2016-11-01 13:58:03
【问题描述】:

我不知道我把test1.jpgtest2.jpg 放在哪里了。

我多次更改此代码,但我不能...

官方api站点在这里:https://dev.projectoxford.ai/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039523a

{"error":{"code":"BadArgument","message":"Request body is invalid."}}

import httplib, urllib, base64

headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '',
}

params = urllib.urlencode({
})

try:
    conn = httplib.HTTPSConnection('api.projectoxford.ai')
    conn.request("POST", "/face/v1.0/verify?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

【问题讨论】:

    标签: python python-2.7 image-recognition microsoft-cognitive face


    【解决方案1】:

    您应该改用requests 库:

    import requests,json
    
    headers = {
        # Request headers
        'Content-Type': 'application/json',
        'Ocp-Apim-Subscription-Key': '',
    }
    
    body = {
     "faceId":"c5c24a82-6845-4031-9d5d-978df9175426",
    "peronId":"815df99c-598f-4926-930a-a734b3fd651c",
    "personGroupId":"sample_group"
    }
    
    try:
    
       r = requests.post("https://api.projectoxford.ai/face/v1.0/verify", json=body,headers=headers)
       print(r.json())
    except Exception as e: # Do whatever error handling you need here.
        print("[Errno {0}] {1}".format(e.errno, e.strerror))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-30
      • 2018-12-02
      • 2017-03-21
      • 2019-06-11
      • 1970-01-01
      • 1970-01-01
      • 2022-10-31
      • 1970-01-01
      相关资源
      最近更新 更多