簡體   English   中英

面部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每當我的程序調用UploadAndDetectFaces時,就可以識別和識別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類型的異常。”

有人知道發生了什么問題或需要進行任何更改以防止錯誤嗎?

將密鑰和端點聲明更改為:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM