Kinect SDK 1 - Skeletons
Written by Mike James   
Friday, 23 March 2012
Article Index
Kinect SDK 1 - Skeletons
Using the GDI
From 3D to 2D

From 3D to 2D

First we need to convert the 3D skeleton co-ordinates into 2D color image co-ordinates:

ColorImagePoint Cloc = 

We now have the x,y pixel co-ordinate of the Head in the video bitmap stored as properties of the ColorImagePoint. 

Assuming we have a method called  markAtPoint(ColorImagePoint p, Bitmap bmp)

which will draw an ellipse centered at the location, we can complete the program with:

  markAtPoint(Cloc, bmap);

The MarkAtPoint method simply uses the GDI to draw an ellipse:

void markAtPoint(ColorImagePoint p, 
Bitmap bmp)
Graphics g = Graphics.FromImage(bmp);
new Rectangle(p.X - 20, p.Y - 20, 40, 40));

Now if you run the program you should see a small red ellipses appear to mark the head of the players.




The complete FrameReady event handler is:

void FramesReady(object sender, 
AllFramesReadyEventArgs e)
ColorImageFrame VFrame =
if (VFrame == null) return;
Bitmap bmap = ImageToBitmap(VFrame);
SkeletonFrame SFrame = e.OpenSkeletonFrame();
if (SFrame == null) return;
Skeleton[] Skeletons =
new Skeleton[SFrame.SkeletonArrayLength];
foreach (Skeleton S in Skeletons)
if (S.TrackingState ==
SkeletonPoint Sloc =
ColorImagePoint Cloc =
markAtPoint(Cloc, bmap);
pictureBox1.Image = bmap;

Once you have seen how to track a head the rest of the body is no problem and you will be surprised at how rarely you actually need to draw a skeleton corresponding to where the player is - which is the topic of the next chapter.


You can download the code for the Windows Forms version of this program from the CodeBin (note you have to register first).

Practical Windows Kinect in C#
Chapter List

  1. Introduction to Kinect
  2. Getting started with Microsoft Kinect SDK 1
  3. Using the Depth Sensor
  4. The Player Index
  5. Depth and Video Space
  6. Skeletons
  7. The Full Skeleton
  8. A 3D Point Cloud






or email your comment to:


To be informed about new articles on I Programmer, subscribe to the RSS feed, follow us on Google+, Twitter, Linkedin or Facebook or sign up for our weekly newsletter.


Further reading:

Avatar Kinect - a holodeck replacement

A Kinect Princess Leia hologram in realtime

Kinect augmented reality x-ray (video)

Kinect flies

Kinect plus a glass wedge gives ...

Kinect makes you Superman

Kinect goes self aware - a warning

Kinect for Microsoft Robots

Kinect knows what you are doing...










Last Updated ( Friday, 27 April 2012 )