【问题标题】:Microsoft Emotions API Get Recognition in Video Operation ResultMicrosoft Emotions API 在视频操作结果中获得认可
【发布时间】:2017-03-15 07:04:35
【问题描述】:

如何使用视频操作结果中的获取识别返回我发布到情绪 api 的视频的状态和结果?

我可以使用我上传的视频的操作 id 成功运行 Get Recognition in Video Operation Result,但响应没有显示视频的状态和情绪 API 的结果,而只显示以下内容:

StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, 
Headers:{ 
Pragma: no-cache 
apim-request-id: 010962c0-f907-4ba3-a7fd-564ddff7f97d 
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload 
Cache-Control: no-cache 
Date: Wed, 02 Nov 2016 02:33:16 GMT 
X-AspNet-Version: 4.0.30319 
X-Powered-By: ASP.NET 
Content-Length: 16048 
Content-Type: application/json; charset=utf-8 Expires: -1 }

我已经尝试在开放的 api 测试控制台中使用相同的 oid

(https://dev.projectoxford.ai/docs/services/5639d931ca73072154c1ce89/operations/56f8d4471984551ec0a0984f/console)

并且响应返回来自情绪 api 的状态和结果。

我正在使用 API 参考中的以下代码:

        var client = new HttpClient();
        var queryString = HttpUtility.ParseQueryString(string.Empty);

        // Request headers
        client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");

        var uri = "https://api.projectoxford.ai/emotion/v1.0/operations/{oid}?" + queryString;

        var response = await client.GetAsync(uri);

【问题讨论】:

    标签: c# api microsoft-cognitive emotion


    【解决方案1】:

    根据您粘贴的内容,您似乎确实收到了响应,即 16048 字节的 JSON。

    由于您使用的是 C#,我认为您可以通过使用由认知服务团队成员编写的 client library 来节省大量精力。如果你使用 Visual Studio,你可以简单地下拉 NuGet 包。

    如果您不想使用预建库,则需要自己解析 JSON。 JSON 将位于response.Content

    【讨论】:

    • 我能够使用以下方法访问响应内容:string responseBody = await response.Content.ReadAsStringAsync();我最初使用的是 C# 的客户端库,但我发现它对我来说太慢了,无法实际使用。感谢您的帮助!
    猜你喜欢
    • 2017-02-27
    • 2016-09-06
    • 2017-03-27
    • 2014-12-19
    • 2016-12-31
    • 2018-07-10
    • 1970-01-01
    • 1970-01-01
    • 2021-11-13
    相关资源
    最近更新 更多