c# - 如何从数据 Kinect SDK C# 中获取播放器深度?

标签 c# kinect

做一个小组项目,试图在玩家(特别是玩家)近/远时发生一些事情,所以我们编写了这个函数。 (我们不允许使用骨架特征)

private void FindDepth(DepthImageFrame depthFrame)
    {

        short[] rawDepthData = new short[depthFrame.PixelDataLength];
        depthFrame.CopyPixelDataTo(rawDepthData);

        Byte[] pixels = new byte[depthFrame.Height * depthFrame.Width * 4];

        for (int depthIndex = 0; depthIndex < rawDepthData.Length; depthIndex++)
        {
            int player = rawDepthData[depthIndex] & DepthImageFrame.PlayerIndexBitmask;
            int depth = rawDepthData[depthIndex] >> DepthImageFrame.PlayerIndexBitmaskWidth;

            if (player > 0)
            {
                playerDepth = rawDepthData[depthIndex];
            }

        }

    }

为什么这不能通过抓取一个像素来正确抓取玩家的深度?

最佳答案

深度像素表示为 16 位。低 3 位提供播放器索引,其余 13 位提供深度,例如{深度位}{播放器索引位}

{0100 1011 1001 0}{010}

因此,为了找到播放器索引,我们通过 DepthImageFrame.PlayerIndexBitmask 进行运算,如下所示

(0100 1011 1001 0010) AND (0000 0000 0000 0111) = 0000 0000 0000 0010 = 2 即第二个玩家

为了找到距离,我们向右移动 3 位,返回 13 位,如下所示 0000 1001 0111 0010 = 2418 即 2418 毫米

关于c# - 如何从数据 Kinect SDK C# 中获取播放器深度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9728545/

相关文章:

c# - 立即重定向到操作

c# - 将 XElement 转换为 XmlNode

c# - 使用 Kinect 和 EMGU(OpenCV 包装器)定位机器人

c# - Kinect 音频 PCM 值

c# - C# 中是否有一个内置类型,其中包含一个 bool 和一个用于静态方法返回的字符串?

c# - 选择 System.Drawing.Icon 的大小?

c# - 从 app.config 中的值创建 map

memory - cvShowImage和Kinect SDK的内存问题:骨架查看器

c++ - 在 C++ 中同时从 Kinect 版本 2 获取颜色和深度帧

opencv - Kinect for XBOX 深度范围限制,用于基于触摸的感应