我正在使用下面的代码来发送我的视频,显然我没有收到错误。但回应却是一片空白。我怎样才能阅读回复?
########### Python 2.7 #############
import httplib, urllib, base64, json
headers = {
# Request headers
'Ocp-Apim-Subscription-Key': 'xxxxxxxxxxxxxxxxxxxx',
'Content-Type': 'application/json'
}
video_filename = {"url":"https://fsarquivoeastus.blob.core.windows.net/public0/WhatsApp-Video-20160727.mp4"}
params = urllib.urlencode({})
try:
conn = httplib.HTTPSConnection('api.projectoxford.ai')
conn.request("POST", "/emotion/v1.0/recognizeinvideo?%s" % params, json.dumps(video_filename), headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))发布于 2016-08-04 05:23:31
包括情感在内的认知服务视频API异步操作,并且在POST成功时按照设计返回一个空的响应体。您必须做的是从头部检索操作URL,如下所示:
response = conn.getresponse()
location = response.getheader('operation-location');
print(location);您可以在该location URL上调用GET来检查操作的状态。更多关于here的信息。
发布于 2016-08-05 21:53:30
@FelipeSouzaLima,要获取视频中情感识别的操作结果,需要完成以下两个步骤。
operation-location头部,下一步会调用,就像@cthrash所说的,operation-location header的值的url,Ocp-Apim-Subscription-Key和request header相同,就可以得到包含识别任务状态的json响应体。如果json响应中status字段的值为Succeeded,则操作结果为json结果中的processingResult字段,请参考Get Recognition in Video Operation Result.的REST接口
https://stackoverflow.com/questions/38751315
复制相似问题