Obtaining joint positions
Before we can consider using the skeleton for gesture-based interaction, we should first print out all the skeletal-joint-related data to have a directly perceived look of the Kinect skeleton positions. The data can then be merged with our color image so that we can see how they are matched with each other in real time.
Drawing the skeleton
We will first draw the skeleton with a series of lines to see how Kinect defines all the skeletal bones.
The Microsoft Kinect SDK uses
NUI_SKELETON_POSITION_COUNT
(equivalent to 20 for the current SDK version) to represent the number of joints of one skeleton, so we define an array to store their positions.GLfloat skeletonVertices[NUI_SKELETON_POSITION_COUNT][3];
Add the following lines for updating a skeleton frame in the
update()
function.NUI_SKELETON_FRAME skeletonFrame = {0}; hr = context->NuiSkeletonGetNextFrame( 0, &skeletonFrame ); if ( SUCCEEDED(hr) ) { // Traverse all possible skeletons in tracking for ( int...