我想创建一个简单的程序来使用 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");
错误返回:
“引发了‘Microsoft.ProjectOxford.Face.FaceAPIException’类型的异常。”
有谁知道出了什么问题或需要进行任何更改来防止错误?