人脸API DetectAsync错误 [英] Face API DetectAsync Error

查看:132
本文介绍了人脸API DetectAsync错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个简单的程序来使用Microsoft Azure Face API和Visual Studio 2015来检测人脸.遵循(

I wanted to create a simple program to detect faces using Microsoft Azure Face API and Visual Studio 2015. Following the guide from (https://social.technet.microsoft.com/wiki/contents/articles/37893.c-face-detection-and-recognition-with-azure-face-api.aspx), whenever my program calls UploadAndDetectFaces:

private async Task<Face[]> UploadAndDetectFaces(string imageFilePath)
{
    try
    {
        using (Stream imageFileStream = File.OpenRead(imageFilePath))
        {
            var faces = await faceServiceClient.DetectAsync(imageFileStream,
                true,
                 true,
                 new FaceAttributeType[] 
                 {
                     FaceAttributeType.Gender,
                     FaceAttributeType.Age,
                     FaceAttributeType.Emotion
                 });
            return faces.ToArray();
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
        return new Face[0];
    }
}

我还声明了终结点的密钥:

I also declared the keys to the endpoint:

private readonly IFaceServiceClient faceServiceClient = new FaceServiceClient("MY_KEY_HERE");

错误返回:

引发了类型为'Microsoft.ProjectOxford.Face.FaceAPIException'的异常."

"Exception of type 'Microsoft.ProjectOxford.Face.FaceAPIException' was thrown."

有人知道发生了什么问题或需要进行任何更改以防止该错误吗?

Does anyone know what's wrong or any changes required to prevent the error?

推荐答案

将键和端点声明更改为:

Change the key and endpoint declaration to:

private readonly IFaceServiceClient faceServiceClient = new FaceServiceClient("MY_KEY_HERE", "ACTUAL_ENDPOINT_HERE");

这篇关于人脸API DetectAsync错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆