简体   繁体   English

面部API DetectAsync错误

[英]Face API DetectAsync Error

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: 我想创建一个简单的程序来使用Microsoft Azure Face API和Visual Studio 2015来检测人脸。按照( https://social.technet.microsoft.com/wiki/contents/articles/37893.c-face-detection每当我的程序调用UploadAndDetectFaces时,就可以识别和识别azure-face-api.aspx ):

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");

an error returns: 错误返回:

"Exception of type 'Microsoft.ProjectOxford.Face.FaceAPIException' was thrown." “引发了'Microsoft.ProjectOxford.Face.FaceAPIException类型的异常。”

Does anyone know what's wrong or any changes required to prevent the error? 有人知道发生了什么问题或需要进行任何更改以防止错误吗?

将密钥和端点声明更改为:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM