0

我想创建一个简单的程序来使用 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’类型的异常。”

有谁知道出了什么问题或需要进行任何更改来防止错误?

4

1 回答 1

0

将键和端点声明更改为:

private readonly IFaceServiceClient faceServiceClient = new FaceServiceClient("MY_KEY_HERE", "ACTUAL_ENDPOINT_HERE");
于 2017-12-20T01:12:30.050 回答