【问题标题】:How to get the Hololens Locatable Camera view and projection matrices out of the WinRT Windows.Media API如何从 WinRT Windows.Media API 中获取 Hololens 可定位相机视图和投影矩阵
【发布时间】:2017-08-23 12:15:29
【问题描述】:

Hololens 的文档提供了一个示例,说明如何使用 Media Foundation API 提取可定位相机视图和投影矩阵:https://developer.microsoft.com/en-us/windows/mixed-reality/locatable_camera#locating_the_device_camera_in_the_world

它声称 WinRT API 也可以做到这一点,并链接到此文档参考:https://docs.microsoft.com/en-us/uwp/api/Windows.Media.Devices.Core.CameraIntrinsics

但是,这个类似乎没有任何 API 来检索扩展的 Hololens 属性,只有默认的 Windows Phone 属性,如失真矩阵和针孔属性。

Hololens 文档是否不正确,是否根本无法在 WinRT API 中检索可定位相机元数据?还是我错过了什么?

空间坐标系(第三个也是最后一个扩展的示例元数据属性)似乎可以作为 MediaFrameReference.CoordinateSystem (https://docs.microsoft.com/en-us/uwp/api/windows.media.capture.frames.mediaframereference) 使用,这使得这更加令人困惑......

【问题讨论】:

    标签: c# windows windows-runtime win-universal-app hololens


    【解决方案1】:

    您可以将捕获的CapturedPhoto 对象强制转换为IMFGetService 接口。然后,您可以使用 MF_WRAPPED_SAMPLE_SERVICE 作为服务 GUID 调用 IMFGetService::GetService 方法,这将为您提供本机 IMFSample。从中,您可以检索文档中概述的这 3 个相机属性(坐标系、视图变换和投影变换)。

    现在,您可以尝试通过手动声明这些接口在 C# 中编写所有这些功能,但在 C++ 中会更容易。

    【讨论】:

      【解决方案2】:

      我也遇到了同样的问题。摄像机的空间坐标系可通过 MediaFrameReference.CoordinateSystem 获得。但是 MediaFrameReference 类中不提供投影矩阵。我通过在 MediaFrameReference.Properties 地图中查找投影矩阵解决了这个问题。基本思想显示为here,但是我需要为 UWP 调整代码。我的工作代码如下所示。

      EXTERN_GUID(MFSampleExtension_Spatial_CameraProjectionTransform, 0x47f9fcb5, 0x2a02, 0x4f26, 0xa4, 0x77, 0x79, 0x2f, 0xdf, 0x95, 0x88, 0x6a);
      
      MediaFrameReference^ frame = ...; // your frame
      auto projectionTransformProperty= (Windows::Foundation::IPropertyValue^)frame->Properties->Lookup(MFSampleExtension_Spatial_CameraProjectionTransform);
      Platform::Array<unsigned char>^ projectionMatrixByteArray = ref new Platform::Array<unsigned char>(4*4*4);
      projectionTransformProperty->GetUInt8Array(&projectionMatrixByteArray);
      float* projectionMatrixValues= reinterpret_cast<float*>(projectionMatrixByteArray->Data);
      //projectionMatrixValues now contains the 16 entries of the projection matrix
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-04-19
        • 2015-04-11
        • 2013-04-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-07-24
        • 1970-01-01
        相关资源
        最近更新 更多