面对 API DetectAsync 错误

Face API DetectAsync Error

我想创建一个简单的程序来使用 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");

一个错误returns:

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

有谁知道出了什么问题或需要进行哪些更改才能防止错误发生?

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

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