Click here to Skip to main content
12,955,959 members (91,098 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


13 bookmarked
Posted 15 Mar 2011

Kinect and WPF: Complete body tracking

, 3 Dec 2013 Ms-PL
Rate this:
Please Sign up or sign in to vote.
Complete body tracking in Kinect.

It's time for a really interesting and useful Kinect tutorial. We'll see how to achieve full body tracking using Kinect sensor, OpenNI library and Windows Presentation Foundation.

I found OpenNI C# samples a little messy, so I decided to develop a .NET 4 wrapper library which could be used into WPF applications whithout requiring .NET 2 staff like GDI+, System.Drawing, etc. I named it Nui.Vision and it's part of a larger framework I currently develop. Nui.Vision is a .NET 4 assembly which offers an easy-to-use body tracking API!

Update 20/04/2011

Nui.Vision is now compatible with the latest release of OpenNI framework ( I have made some changes and bug-fixes to it, including the skeleton-display fix provided by roni26_wu (see comments below). An open-source version of Nui.Vision is coming soon!


Using the Library

Using Nui.Vision is a piece of cake. All body tracking is done in the background, so you only need to update your user interface when the proper events fire. Firstly, add a reference to and Nui.Vision.dll. Also import a valid configuration file to your project, as described here. Do not forget to type the corresponding using statement:

using Nui.Vision;

Then declare a new NuiUserTracker object and initialize it in the constructor. Provide the path of the configuration file you previously imported (do not forget to paste the same file in the Debug/Release folders of your application):

_skeleton = new NuiUserTracker("SamplesConfig.xml");

Just below that, you need to define the UserUpdated event.

_skeleton.UsersUpdated += new NuiUserTracker.UsersUpdatedHandler(Skeleton_UserUpdated);

A proper event handler is created. The NuiUserEventArgs parameter provides you with a collection of all the recognized users! You can now get the coordinates (X, Y and Z) of every body part of every user (OpenNI currently supports 15 body parts)!

foreach (var user in e.Users) {
    float headX = user.Head.X;
    float headY = user.Head.Y;
    float headZ = user.Head.Z;
    float neckX = user.Neck.X;
    float neckY = user.Neck.Y;
    // etc... 

Quite easy, huh?

Here is a list of all the available body parts:

  • Head
  • Neck
  • LeftShoulder
  • LeftElbow
  • LeftHand
  • RightShoulder
  • RightElbow
  • RightHand
  • Torso
  • LeftKnee
  • LeftHip
  • LeftFoot
  • RightKnee
  • RightHip
  • RightFoot

You may now start developing cool WPF Kinect applications and games. Imagination's the limit.


This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


About the Author

Vangos Pterneas
CEO LightBuzz
United States United States
Vangos Pterneas is a Microsoft Most Valuable Professional in the Kinect technology. He helps companies from all over the world grow their revenue by creating profitable software products. Vangos is the founder of LightBuzz Inc. and author of two technical books.

You may also be interested in...

Comments and Discussions

Generalmay I ask you a question? Pin
kouna19-Jun-12 19:23
memberkouna19-Jun-12 19:23 
QuestionThanks so much! Pin
duong21795-Jan-12 22:32
memberduong21795-Jan-12 22:32 
Questionimage raw and depth map and labelmap are not sync Pin
makoos23-May-11 21:13
membermakoos23-May-11 21:13 
Questionpoint cloud generating Pin
makoos22-May-11 23:09
membermakoos22-May-11 23:09 
AnswerRe: point cloud generating Pin
Vangos Pterneas24-May-11 15:34
memberVangos Pterneas24-May-11 15:34 
GeneralGreat! but some trouble... Pin
Jonas Toftefors29-Apr-11 3:50
memberJonas Toftefors29-Apr-11 3:50 
QuestionProblem with latest version Pin
cedtat123-Apr-11 11:50
membercedtat123-Apr-11 11:50 
AnswerRe: Problem with latest version Pin
Vangos Pterneas24-Apr-11 9:49
memberVangos Pterneas24-Apr-11 9:49 
GeneralRe: Problem with latest version [modified] Pin
cedtat124-Apr-11 11:28
membercedtat124-Apr-11 11:28 
Oh I get it, just cleaning my solution solved the problem.
Great job ! This is amazng how those points are stcking to me Smile | :)

I don't know how your algorythm is working but it may be great if there was (if possible) some parameters to tweek in a config file. Don't know if it can be a good idea.

Just to give you a feedback, I am detected properly at a 30-40% rate. I am not sure how to behave while it is searching for me, sometimes it can take some time and I don't know if there is a particular posture that can help detect the body. Maybe if you can give us some hints on this part.

[EDIT] ... ok I know now what is the posture to detect properly the user, 100% detection now and pretty quick when you know how to do ! Really cool ! Maybe you should add a picture of the posture.

Nice job,

modified on Sunday, April 24, 2011 6:03 PM

GeneralAWESOME! [modified] Pin
henrygoro25-Mar-11 3:40
memberhenrygoro25-Mar-11 3:40 
GeneralRe: AWESOME! Pin
Vangos Pterneas24-Apr-11 9:47
memberVangos Pterneas24-Apr-11 9:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170525.1 | Last Updated 3 Dec 2013
Article Copyright 2011 by Vangos Pterneas
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid