Face API DetectAsync Error

走远了吗. 提交于 2019-12-02 17:07:40

问题


I wanted to create a simple program to detect faces using Microsoft Azure Face API and Visual Studio 2015. Following the guide from (https://social.technet.microsoft.com/wiki/contents/articles/37893.c-face-detection-and-recognition-with-azure-face-api.aspx), whenever my program calls 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];
    }
}

I also declared the keys to the endpoint:

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

an error returns:

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

Does anyone know what's wrong or any changes required to prevent the error?


回答1:


Change the key and endpoint declaration to:

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


来源:https://stackoverflow.com/questions/47885650/face-api-detectasync-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!