face api例外:无法对响应进行估算

发布于 2025-02-09 20:27:11 字数 1984 浏览 2 评论 0原文

我正在使用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.

This is the debug output:
enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

肤浅与狂妄 2025-02-16 20:27:11

为了在当前版本中执行反序列化方法,建议将响应转换为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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文