【问题标题】:Face Detection in AzureAzure 中的人脸检测
【发布时间】:2019-05-18 00:24:46
【问题描述】:

我正在尝试使用 Microsoft Azure 认知服务人脸检测。我做错了什么。我正在尝试使用 C# SDK 进行人脸检测。我收到以下错误。我什至不知道如何调试它或错误消息告诉我什么。它几乎就像我设置的东西没有通过,但我只是在猜测。

 Microsoft.Azure.CognitiveServices.Vision.Face.Models.APIErrorException
  HResult=0x80131500
  Message=Operation returned an invalid status code 'BadRequest'
  Source=Microsoft.Azure.CognitiveServices.Vision.Face
  StackTrace:
   at Microsoft.Azure.CognitiveServices.Vision.Face.FaceOperations.<DetectWithUrlWithHttpMessagesAsync>d__9.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Microsoft.Azure.CognitiveServices.Vision.Face.FaceOperationsExtensions.<DetectWithUrlAsync>d__4.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at BWD.ASPNET.Core.Services.FaceDetection.<DoWork>d__5.MoveNext() in 

我的调用代码是:

    string faceEndpoint = "https://eastus.api.cognitive.microsoft.com";
    FaceAttributeType[] faceAttributes =
    { FaceAttributeType.Age, FaceAttributeType.Gender, FaceAttributeType.Hair, 
        FaceAttributeType.Smile, FaceAttributeType.Gender, FaceAttributeType.Emotion, FaceAttributeType.FacialHair, 
        FaceAttributeType.Accessories  };
    FaceClient faceClient = new FaceClient( new ApiKeyServiceClientCredentials(connString), new System.Net.Http.DelegatingHandler[] { });
    faceClient.Endpoint = faceEndpoint;
    var ctx = new BWDContext();
    var pics = await (from p in ctx.Picture where p.DateOfFacial == null select p).ToListAsync();
    foreach(var pic in pics)
    {
        if(Uri.IsWellFormedUriString(pic.PicFileUrl, UriKind.Absolute))
        {
            IList<DetectedFace> faceList =
                await faceClient.Face.DetectWithUrlAsync(pic.PicFileUrl, true, true, faceAttributes); // error occurs here
 .....on and on .......

我还尝试使用 fiddler 进行休息呼叫,这确实有效。在提琴手通话中,我只是在这个网址上发了一个帖子:https://eastus.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes=age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise

我的标题是:

User-Agent: Fiddler
Ocp-Apim-Subscription-Key: ....subscription key......
Content-Type: application/json
Host: eastus.api.cognitive.microsoft.com
Content-Length: 107

我的帖子正文是: { '网址': 'https://bwdpictures.blob.core.windows.net/bwdpictures/d916acdd-ab9f-429e-8b75-6d5f9206a9b4.jpg' }

我从提琴手的其余调用中得到结果。

我确定问题出在我的代码上,但我不知道问题出在哪里。如果您有一些建议,我将不胜感激。

TIA, 沃利

【问题讨论】:

  • 代码在原帖中。

标签: azure azure-cognitive-services


【解决方案1】:

宾果游戏。问题是我在面部属性中有两次性别属性。我只是注意到了。当我拿出第二个时,问题就解决了。抱歉发帖了。

【讨论】:

    猜你喜欢
    • 2018-12-31
    • 2012-04-17
    • 2019-11-18
    • 2013-09-24
    • 1970-01-01
    • 2019-12-01
    • 2013-07-16
    • 1970-01-01
    • 2012-03-08
    相关资源
    最近更新 更多