Question

I am working with kinect, and I wanted to print on the screen a single joint. The example does this:

foreach (Joint joint in skeleton.Joints){

 Brush drawBrush = null;
 drawingContext.DrawEllipse(drawBrush, null, this.SkeletonPointToScreen(joint.Position),JointThickness,JointThickness)

}

That draws all of the joints, and currently I would like to be able to draw only those I am interested in. This is what I've been doing:

 Joint Cadera = skeleton.Joints[0];

                Brush drawBrush = null;

     if (drawBrush != null)
                {
                    drawingContext.DrawEllipse(drawBrush, null, this.SkeletonPointToScreen(Cadera.Position), JointThickness, JointThickness);
                }

but when I change skeleton.Joints[0] to skeleton.Joint[1] I get the following error:

cannot convert from 'int' to 'Microsoft.Kinect.JointType'

that does not happen when using 0. Since I am a novice c# programmer I would like to know how to access specific elements of a collection. I have taken a look at the class JointCollection and it shows this :

 namespace Microsoft.Kinect
 {
  // Summary:
  //     This class contains a collection of joints returned for a given skeleton.
     [Serializable]
        public class JointCollection : IEnumerable<Joint>, IEnumerable
      {
       // Summary:
        //     Gets the number of joints available.
        public int Count { get; }

      // Summary:
      //     Accesses the requested joint.
      //
      // Parameters:
      //   jointType:
      //     The JointType being requested.
      //
       // Returns:
     //     The requested joint.
      public Joint this[JointType jointType] { get; set; }

    // Summary:
    //     This method is used to enumerate the list of joints.
    //
    // Returns:
    //     The related enumerator.
    public IEnumerator GetEnumerator();
  }
}

So, I believe I need to use Joint, but I don't know how. Thanks in advance for any help

Was it helpful?

Solution

You are using an int as an index for Skeleton.Joints[].

You are supposed to reference the Skeleton.Joints[] with a JointType. For example:

Joint hand = skeleton.Joints[JointType.HandLeft];

This will create a duplicate of the Skeleton's left hand joint. See the JointType reference for the values in the enum.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top