Face API DetectAsync错误

问题描述 投票:0回答:1

我想创建一个简单的程序来使用Microsoft Azure Face API和Visual Studio 2015来检测面部。按照(https://social.technet.microsoft.com/wiki/contents/articles/37893.c-face-detection-and-recognition-with-azure-face-api.aspx)的指南,每当我的程序调用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];
    }
}

我还声明了端点的键:

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

错误返回:

“抛出了'Microsoft.ProjectOxford.Face.FaceAPIException'类型的异常。”

有谁知道什么是错误或防止错误所需的任何更改?

c# visual-studio azure face-api
1个回答
0
投票

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

private readonly IFaceServiceClient faceServiceClient = new FaceServiceClient("MY_KEY_HERE", "ACTUAL_ENDPOINT_HERE");
© www.soinside.com 2019 - 2024. All rights reserved.