face api例外:无法对响应进行估算
我正在使用Unity 2021.3.4F1在HoloLens 2上执行面部识别的应用程序。在编辑器中一切正常时,我在HoloLens上运行该应用程序时遇到了麻烦。 我正在使用Microsoft Azure认知服务面对API版本2.8.0.0,如所述identity-detect-faces" rel="nofollow noreferrer">here or
这是我使用的代码中的片段:
private async Task DetectFaceExtractAsync(IFaceClient client, string filepath, string recognitionModel)
{
Debug.Log("--- DETECT FACE ---");
IList<DetectedFace> detectedFaces;
// Specify facial features to be retrieved
List<FaceAttributeType> features = new List<FaceAttributeType>
{
FaceAttributeType.Blur, FaceAttributeType.Emotion, FaceAttributeType.Exposure, FaceAttributeType.HeadPose,
FaceAttributeType.Noise, FaceAttributeType.Occlusion, FaceAttributeType.Smile, FaceAttributeType.QualityForRecognition
};
// Detect faces with all attributes from image.
try
{
using (FileStream faceimagestream = File.OpenRead(filepath))
{
detectedFaces = await client.Face.DetectWithStreamAsync(
faceimagestream,
returnFaceAttributes: features,
detectionModel: DetectionModel.Detection01,
recognitionModel: recognitionModel);
}
}
catch (Exception e)
{
Debug.Log("Exception: " + e.Message);
throw e;
}}
在收到Azure的响应时,我将获得“无法对响应的响应”异常。由于某种原因,此例外不会发生在编辑器中,只有在图像中应识别面部时才发生。如果图像中没有面部,则显然可以应对响应。
更新:
如果我索要以下功能,也会发生例外,该功能仍应提供21.06.22的新限制:
List<FaceAttributeType> features = new List<FaceAttributeType>
{
FaceAttributeType.Blur, FaceAttributeType.Exposure, FaceAttributeType.HeadPose,
FaceAttributeType.Noise, FaceAttributeType.Occlusion, FaceAttributeType.QualityForRecognition
};
I am working on an app that performs face recognition on the Hololens 2 using Unity 2021.3.4f1. I'm having trouble running the app on the Hololens while everything works fine in the editor.
I'm using the Microsoft Azure Cognitive Services face API Version 2.8.0.0 as described here or here.
This is a snippet from the code I use:
private async Task DetectFaceExtractAsync(IFaceClient client, string filepath, string recognitionModel)
{
Debug.Log("--- DETECT FACE ---");
IList<DetectedFace> detectedFaces;
// Specify facial features to be retrieved
List<FaceAttributeType> features = new List<FaceAttributeType>
{
FaceAttributeType.Blur, FaceAttributeType.Emotion, FaceAttributeType.Exposure, FaceAttributeType.HeadPose,
FaceAttributeType.Noise, FaceAttributeType.Occlusion, FaceAttributeType.Smile, FaceAttributeType.QualityForRecognition
};
// Detect faces with all attributes from image.
try
{
using (FileStream faceimagestream = File.OpenRead(filepath))
{
detectedFaces = await client.Face.DetectWithStreamAsync(
faceimagestream,
returnFaceAttributes: features,
detectionModel: DetectionModel.Detection01,
recognitionModel: recognitionModel);
}
}
catch (Exception e)
{
Debug.Log("Exception: " + e.Message);
throw e;
}}
When receiving a response from Azure I get an "Unable to deserialize the response" Exception. For some reason, this exception does not occur in the editor and only occurs when a face should be recognizable from the image. If there is no face in the image, the response is apparently deserializable.
Update:
The exception also occurs if I ask for the following features, which should still be available with the new limitations from the 21.06.22:
List<FaceAttributeType> features = new List<FaceAttributeType>
{
FaceAttributeType.Blur, FaceAttributeType.Exposure, FaceAttributeType.HeadPose,
FaceAttributeType.Noise, FaceAttributeType.Occlusion, FaceAttributeType.QualityForRecognition
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了在当前版本中执行反序列化方法,建议将响应转换为JSON,然后执行供应序列化。如官方文档,建议与JSON一起执行face API的挑战。 HoloLens 2 是缺少概念,那里没有官方程序来处理版本2的错误。
To perform the deserialization method in the current version, it is suggestable to convert the response into JSON and then perform deserialization. As mentioned in the official documentation, deserialization in Face API is suggestable to perform with JSON. The Hololens 2, is missing concept, where there are no official procedures to handle the errors occurring with version 2.