【发布时间】:2015-12-02 20:00:46
【问题描述】:
我正在尝试将来自 KinectV2 的深度数据映射到 Unity-Script 中的色彩空间。 它使用通常的坐标映射器功能按预期工作
_sensor.CoordinateMapper.MapDepthFrameToColorSpace(_depthData, _colorSpacePoints)
但它使我的帧率降低了 11 - 这是不可接受的 =)
因此,我查看了 Microsoft 提供的统一示例,并找到了一些 使用指针进行映射。
var pDepthData = GCHandle.Alloc(pDepthBuffer, GCHandleType.Pinned);
var pDepthCoordinatesData = GCHandle.Alloc(m_pDepthCoordinates, GCHandleType.Pinned);
m_pCoordinateMapper.MapColorFrameToDepthSpaceUsingIntPtr(
pDepthData.AddrOfPinnedObject(),
(uint)pDepthBuffer.Length * sizeof(ushort),
pDepthCoordinatesData.AddrOfPinnedObject(),
(uint)m_pDepthCoordinates.Length);
pDepthCoordinatesData.Free();
pDepthData.Free();
也存在满足我需求的等效方法。我尝试了指针版本 MapDepthFrameToColorSpace
var pDepthData = GCHandle.Alloc(pDepthBuffer, GCHandleType.Pinned);
var pColorData = GCHandle.Alloc(m_pColorSpacePoints, GCHandleType.Pinned);
m_pCoordinateMapper.MapDepthFrameToColorSpaceUsingIntPtr(
pDepthData.AddrOfPinnedObject(),
pDepthBuffer.Length * sizeof(ushort),
pColorData.AddrOfPinnedObject(),
(uint)m_pColorSpacePoints.Length * sizeof(float) * 2);
pColorData.Free();
pDepthData.Free();
pDepthBuffer 在方法调用时具有有效数据,并且 m_pColorSpacePoints 已初始化并且 具有与 pDepthBuffer 相同的长度(如 MSDN 文档中推荐的那样) 我仍在使用 1408 SDK 版本。 函数后的结果是一个具有 Empty/NegativeInfinity 浮点值且没有有效值的数组 颜色空间点。也没有错误消息。 有什么建议吗?
【问题讨论】: