首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Kinect深度相机中隔离播放器

在Kinect深度相机中隔离播放器
EN

Stack Overflow用户
提问于 2013-03-03 11:54:10
回答 1查看 631关注 0票数 1

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

代码语言:javascript
复制
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会发生变化,并导致在纹理中绘制的人是新的人。

EN

回答 1

Stack Overflow用户

发布于 2013-03-03 12:33:32

好了,我知道怎么做了。

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15182288

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档