none
How to check if some part of the body is not being Tracked ? RRS feed

  • Question

  • Hi

    I want to display a message if the Left-shoulder is not being tracked. I have written the following code, but it always displayed the message 'Not Tracked' even if the shoulder is being tracked. Kindly guide me how to display a message if some specific part of the body is not being tracked.

    I am creating this application in Microsoft XNA.

    Following is just the part of the code to make things clearer.

     Joint leftShoulder;           
    string str="";   
    
        
    protected override void LoadContent()
    {            
    if(_skeletons.Length >0)          
      {                
    isSkeleton = true;                
    foreach (Skeleton skl in _skeletons )                {                  
     leftShoulder = skl.Joints[JointType.ShoulderLeft];
    }       
    
    
    
    protected override void Update(GameTime gameTime)       {                    
    if (leftShoulder.TrackingState == JointTrackingState.Tracked)
                {               
     str = "Tracked";           
     }           
     else             
    {                
    str = "Not Tracked!";                    
        }       
     }     
    
    
    
    protected override void Draw(GameTime gameTime)
    {  
    spriteBatch.DrawString(LoadItems, str, new Vector2(loadContentFontX, loadContentFontY), Color.Black);
    }

                  


    Thursday, November 7, 2013 7:00 AM

Answers

  • I see 2 possible mistakes in the code:

    • Kinect returns an array with 6 skeletons even if there is only one player visible (you will get 1 tracked skeleton and 5 positionOnly skeletons).
      Looping accross all skeletons will override a tracked shoulder by a not tracked one.
      So, you should only retrieve the joint (shoulder) if skeleton.TrackingState == SkeletonTrackingState.Tracked
    • Knowing that XNA LoadContent method is called only once when starting the game and Skeleton reference will change during the lifecycle of the app (CopySkeletonData creates new skeletons), you just can't reference once the joint at startup.
      You need to retrieve the shoulder joint INSIDE the FrameReady method 

    Hope this helps


    Vincent Guigui Innovative Technologies Expert at OCTO Technology MVP Kinect

    Thursday, November 7, 2013 8:49 AM