我从github使用了这个项目:https://github.com/jernejk/RealTimeFaceApi,但结果始终显示“获取身份失败”。
我的键和端点是正确的,但是我不确定“ FaceGroupId”的值是否表示persongroupId?(我在这里使用personGroupId。)
我想知道先前步骤中是否存在错误?
以下代码显示了需要更改的三个地方:
public static class Program
{
// TODO: Add Face API subscription key.
private static string FaceSubscriptionKey = "myFaceAPIkey";
// TODO: Add face group ID.
private static string FaceGroupId = "XXX";//I use persongroupId here.
private static readonly Scalar _faceColorBrush = new Scalar(0, 0, 255);
private static FaceClient _faceClient;
private static Task _faceRecognitionTask = null;
public static void Main(string[] args)
{
_faceClient = new FaceClient(new ApiKeyServiceClientCredentials(FaceSubscriptionKey))
{
Endpoint = "https://myendpoint.cognitiveservices.azure.com/face/v1.0"
};
string filename = args.FirstOrDefault();
Run(filename);
}
我成功地在我这边运行了这个项目。是的,FaceGroupId
应该是您在Face API服务中创建的persongroupId
。出现错误的原因:Getting identity failed.
在Endpoint
中的_faceClient
值有问题,这里的值应该是:
https://<yourEndpoint>.cognitiveservices.azure.com
会好的。如果您使用识别模型02创建和训练您的人员组,您应该知道一件事,请从以下位置修改Program.cs
中的代码:
var detectedFaces = await _faceClient.Face.DetectWithStreamAsync(stream, true, true);
至:
var detectedFaces = await _faceClient.Face.DetectWithStreamAsync(stream,true,true,null, "recognition_02");
如果您使用的是识别模型01,则无需更改(我使用的是02模型)。
希望有帮助。