How to track ONE person with Kinect (trackingID)
Asked Answered
S

1

9

I would like to track the first person, and use this person's right hand to navigate in the application that I made.

I can take over the cursor, now I just want only one person being tracked. So basically when one person is navigating in the program, and there are people walking behind him or are looking with this guy, if they move, the kinect shouldn't recognise anyone else.

How can I implement this, I know it's something with the trackingId but what? :s

        foreach (SkeletonData s in allSkeletons.Skeletons)
        {

                if (s.TrackingState == SkeletonTrackingState.Tracked)
                {
                    if (s.TrackingID == 0)
                    {

                        foreach (Joint joint in s.Joints)
                        {
                        }
                    }
                }
        }
Sophiasophie answered 9/12, 2011 at 8:37 Comment(0)
P
6

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 scope
int 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

Pimple answered 9/12, 2011 at 8:49 Comment(10)
So actually u made a class of a player ? In this class u store an player id, this playerID and this playerID stores the array of skeleton ?Sophiasophie
I checked it out, this means i have to make a class, of player, after that a class of bones, to just track one persons action. Couldnt it be simpeler then it looks :)Sophiasophie
Actually this code is from the ShapeGame. In your code the allSkeletons variable holds a list of all players. If you use the index of every player as identifier for it, you can skip the others.Pimple
ok im looking in to it! I dont understand this "int playerIdx = depthFrame16[i16] & 0x07;" Where or what is depthframe ?Sophiasophie
you don't need to make these classes. you can just remember your player index and the skip the other players. see edit abovePimple
you can access the raw data of the depth camera. this delivers a picture with depth infos. in that picture every pixel holds depth info and the index of the player the kinect recognices. But using this info is more complex than just using the skeleton the SDk offers.Pimple
I am alone to test it, i can test it later with someone, but actually i dont need the s.TrackinID that is builed in the SDK? or am i wrong ?Sophiasophie
Ok i tested it, it works, i have another qs do i have to close this post and make a new one, or i can ask it here ?Sophiasophie
You should probably open a new question except it is the same issue.Pimple
i am tracking the user using tracking id If the another user is tracked i want to start the application if it is half done with the first userFurst

© 2022 - 2024 — McMap. All rights reserved.