我想创建一个简单的程序来使用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'类型的异常。”
是否有人知道什么是错误的或者为防止错误而需要进行任何更改?
答案 0 :(得分:0)
将密钥和端点声明更改为:
private readonly IFaceServiceClient faceServiceClient = new FaceServiceClient("MY_KEY_HERE", "ACTUAL_ENDPOINT_HERE");