none
How to track two skeletons with kinect?? RRS feed

  • Question

  • I'm doing a project (game pong) to college. I can recognize one skeleton and make gestures to control one painel. I searched and I tried to recognize two skeletons to control the another painel, but I can't do it.

     This is what I have so far:

    private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
            {
                Skeleton[] skeletons = new Skeleton[0];
    
                using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
                {
                    if (skeletonFrame != null)
                    {
                        skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                        skeletonFrame.CopySkeletonDataTo(skeletons);
                    }
                    if (skeletons.Length != 0)
                    {
                        foreach (Skeleton skel in skeletons)
                        {
                            if (skel.TrackingState == SkeletonTrackingState.Tracked)
                            {
                                this.tracked(skel);
                            }
                        }
                    }
                }
            }
    
            public void tracked(Skeleton skeleton)
            {
                Joint jHandRight = skeleton.Joints[JointType.HandRight];
                Joint jHipCenter = skeleton.Joints[JointType.HipCenter];
                if ((jHipCenter.Position.Z - jHandRight.Position.Z) > 0.2)
                {
                    //Consider hand raised in front of them
                    //System.Diagnostics.Debug.WriteLine("Hand: Raised");
                    //MessageBox.Show("POR FAVORRRRRRRR");
                    //movement[0] = false;
                    movement[0] = true;
                    movement[1] = false;
                }
                else
                {
                    //Hand is lowered by the users side
                    //System.Diagnostics.Debug.WriteLine("Hand: Lowered");
                    //MessageBox.Show("A SERRRRIIIIIOOOOOOOOOOOOOO");
                    //movement[1] = false;
                    movement[1] = true;
                    movement[0] = false;
                }
            }
    

    Anyone could help me, please.



    Monday, June 23, 2014 2:59 PM

All replies

  • There is a logic problem in your code

    foreach (Skeleton skel in skeletons)
    {
      if (skel.TrackingState == SkeletonTrackingState.Tracked)
      {
        this.tracked(skel);
      }
    }

    You must define a way to distinguish one skeleton to another and do a specific action for each.

    For example, you can use the global skeleton position to define which panel has to be control by the skeleton.

    foreach (Skeleton skel in skeletons)
    {
      if (skel.TrackingState == SkeletonTrackingState.Tracked)
      {
        if (skel.Position.X < 0) // user on the left side
          this.controlLeftPanel(skel);
        else // user on the right side
          this.controlRightPanel(skel);
      }
    }


    Vincent Guigui Innovative Technologies Expert at OCTO Technology Kinect For Windows MVP award

    Thursday, June 26, 2014 7:55 AM