【问题标题】:Face API DetectAsync Error人脸 API DetectAsync 错误
【发布时间】:2018-06-01 19:27:03
【问题描述】:

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

我还声明了端点的键:

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

返回错误:

“引发了‘Microsoft.ProjectOxford.Face.FaceAPIException’类型的异常。”

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

【问题讨论】:

  • 什么是完整的 ErrorMessage & ErrorCode(您可能需要捕获 FaceAPIException 或强制转换异常)。
  • 您可能还需要指定获得密钥时获得的实际端点 - 默认值可能不正确(new FaceServiceClient("MY_KEY_HERE", "ACTUAL ENDPOINT HERE") ;)。请参阅此tutorial。另一个原因可能是图像太大。正如我所说,检查异常的 ErrorMessage 和 ErrorCode - 他们提供了更多细节。
  • @PaulF 谢谢!我使用了 (new FaceServiceClient("MY_KEY_HERE", "ACTUAL ENDPOINT HERE");) 并且它有效

标签: c# visual-studio azure face-api


【解决方案1】:

将键和端点声明更改为:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-23
    • 2018-01-06
    • 2019-06-10
    • 2016-08-09
    • 2018-05-01
    • 1970-01-01
    • 2023-03-19
    • 2023-03-25
    相关资源
    最近更新 更多