c++ - 在 Kinect 深度相机中隔离玩家

标签 c++ kinect

我正在尝试通过 Kinect 深度摄像头隔离单个玩家。我正在打开一个 NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX 流来处理播放器/深度信息。我用来绘制玩家的代码是这样的:

if (LockedRect.Pitch != 0 ) {
      USHORT* curr = (USHORT*) LockedRect.pBits;
      const USHORT* dataEnd = curr + ((width/2)*(height/2));
      index = 0;

      while (curr < dataEnd && playerId != 0) {
        USHORT depth     = *curr;
        USHORT realDepth = NuiDepthPixelToDepth(depth);
        BYTE intensity = 255;
        USHORT player    = NuiDepthPixelToPlayerIndex(depth);


        // Only colour in the player
        if (player == playerId) {
          for (int i = index; i < index + 4; i++)
            dest[i] = intensity;
        }
        else {
          for (int i = index; i < index + 4; i++)
            dest[i] = 0;
        }
        index += 4;
        curr += 1;                                                                
      }    
 }

dest 是一个 OpenGL 纹理。

我遇到的问题是,当第二个人进入框架时,变量 player 发生变化,导致纹理中绘制的人成为新人。

最佳答案

好的,我知道怎么做了。

我需要获取映射到深度像素用户(1 到 6)的骨架 ID(0 到 5)。因此,当传感器发现骨架时,它会保存 ID,并将其设置为 playerId。 PlayerId 仅在其关联骨架被传感器丢失时才会被清除。

关于c++ - 在 Kinect 深度相机中隔离玩家,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15182288/

相关文章:

c++ - 嵌套名称说明符中使用的不完整类型,为什么?

c# - 设置两个kinect : v1 and v2

C++ : initialize(new) an array of vector of different initial size

c++ - 循环重复次数超过应有次数的问题

c++ - 旋转的关节位置

kinect - 从 kinect 保存的图像是黑色的

c++ - 使用 openNi/NITE 从 Kinect 生成 jpeg 图像

适用于 Xbox 360 的 Kinect 和 Kinect SDK 1.5

c++ - 无法获取输出 union 集

c++ - Opengl sws_scale 不工作(段错误)