How to track ONE person with Kinect (trackingID) How to track ONE person with Kinect (trackingID) wpf wpf

How to track ONE person with Kinect (trackingID)


Every tracked person has a player index. Just ignore players with other indexes.
The player index is part of the data in the depth stream image. You have to extract it:

int playerIdx = depthFrame16[i16] & 0x07;

In order to get this info you have to initialize your Kinect Runtime correctly:

_kinectNui.Initialize(RuntimeOptions.UseDepthAndPlayerIndex | ....

See here for more infos:http://www.codeproject.com/KB/dotnet/KinectGettingStarted.aspx

I totally recommend this video tutorial from MS:http://research.microsoft.com/apps/video/?id=152249

If you look in the ShapeGameDemo that is coming with the SDK you can see how they do it. (They just use the index of the skeletion in the array):

int playerId = 0;foreach (SkeletonData data in skeletonFrame.Skeletons) {   if (SkeletonTrackingState.Tracked == data.TrackingState) {      Player player;      if (players.ContainsKey(playerId))         player = players[playerId];      else         player = new Player(playerId);   }   playerId++;}

Simplifying things you can do that (using your code):

int myPlayerIndex = 0; //probably 0 since you are the first person entered the kinect scopeint playerId = 0;foreach (SkeletonData s in allSkeletons.Skeletons) {   if(playerId != myPlayerIndex)      continue;          if (s.TrackingState == SkeletonTrackingState.Tracked) {      foreach (Joint joint in s.Joints)      {      }   }   playerId++;}

To round things up here is a similar question in an MS forum that explains it: http://social.msdn.microsoft.com/Forums/en-US/kinectsdk/thread/d821df8d-39ca-44e3-81e7-c907d94acfca