2013-03-03 2 views
1

Kinect 깊이 카메라를 통해 단일 플레이어를 격리하려고합니다. 플레이어/깊이 정보를 처리하기 위해 NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX 스트림을 여는 중입니다. 내가 선수를 그릴 사용하고 코드는 다음과 같습니다Kinect Depth 카메라에서 플레이어 분리

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

나는 그것을하는 방법을 이해했다.

깊이 픽셀 사용자 (1 ~ 6)에 매핑되는 골격 ID (0 ~ 5)를 가져와야했습니다. 센서가 뼈대를 발견하면 ID를 저장하고이를 playerId로 설정합니다. PlayerId는 관련 뼈대가 센서에 의해 손실 될 때만 지워집니다.

관련 문제