none
How to create my own Joint object as the JointType is "internal set"? (SDK 1.0) RRS feed

  • Question

  • Hi all,

    I have created an application for writing all joint data value from a Skeleton object onto a CSV file. However, I found that, with the new SDK 1.0, the JointType value from the Joint class is "internal set" and thesefore the retrieved data from the CSV file cannot copy back to a new created Skeleton object.

    Does anyone have any idea how to deal with this?

    Many thanks in advance!

    CH Fong

    Monday, February 20, 2012 9:56 AM

Answers

  • Implement a function to read each joint from your CSV file:

            bool ReadJointFromCSV(out JointType jointType, out JointTrackingState trackingState, out SkeletonPoint position)
    

    This function should return false when there are no more joints available for the current skeleton.

    Then, implement a function that reads the joints and stores them in the skeleton:

            Skeleton ReadSkeletonFromCSV()
            {
                Skeleton skeleton = new Skeleton();
                JointType jointType;
                JointTrackingState trackingState;
                SkeletonPoint position;
                while (ReadJointFromCSV(out jointType, out trackingState, out position))
                {
                    Joint joint = skeleton.Joints[jointType];
                    joint.TrackingState = trackingState;
                    joint.Position = position;
                    skeleton.Joints[jointType] = joint;
                }
                return skeleton;
            }
    

    John
    K4W Dev

    Monday, February 20, 2012 8:50 PM

All replies

  • Implement a function to read each joint from your CSV file:

            bool ReadJointFromCSV(out JointType jointType, out JointTrackingState trackingState, out SkeletonPoint position)
    

    This function should return false when there are no more joints available for the current skeleton.

    Then, implement a function that reads the joints and stores them in the skeleton:

            Skeleton ReadSkeletonFromCSV()
            {
                Skeleton skeleton = new Skeleton();
                JointType jointType;
                JointTrackingState trackingState;
                SkeletonPoint position;
                while (ReadJointFromCSV(out jointType, out trackingState, out position))
                {
                    Joint joint = skeleton.Joints[jointType];
                    joint.TrackingState = trackingState;
                    joint.Position = position;
                    skeleton.Joints[jointType] = joint;
                }
                return skeleton;
            }
    

    John
    K4W Dev

    Monday, February 20, 2012 8:50 PM
  • Yes, this is a bug in the documentation. In order to set a joint of a skeleton, you need to obtain the existing joint, update its properties, and then set it again:

    foreach (Joint joint in skeleton.Joints)
    {
        // modify any joint properties (other than JointType) here...
    
        // put joint back into skeleton
        skeleton.Joints[joint.JointType] = joint;
    }
    

    John
    K4W Dev

    Monday, March 12, 2012 5:24 PM
  • Hi Guys,

    I am fairly new to the Kinect development, an I am trying to migrate into the 1.0 SDK a cool example I found for using Kinect and the HTML5 Canvas.

    So far I think I've figured most of the stuff, but I can't seem to get this one. the xample creates a JSON object in order to pas the joint and skeleton info into the client side. But with the JoinType being "internal  set" now. I don't know know how to preoceed. AS you can imagine I am getting the "read only error when trying to set the JointType.

    **Original bet SDK code:

     public static Joint ScaleTo(this Joint joint, int width, int height, float skeletonMaxX, float skeletonMaxY)
            {
                Vector pos = new Vector()
                {
                    X = Scale(width, skeletonMaxX, joint.Position.X),
                    Y = Scale(height, skeletonMaxY, -joint.Position.Y),
                    Z = joint.Position.Z,
                    W = joint.Position.W
                };


                Joint j = new Joint()
                {
                    ID = joint.ID,
                    TrackingState = joint.TrackingState,
                    Position = pos
                };


                return j;

    --------------------------------------------My migrated code----------------------------------

    public static Joint ScaleTo(this Joint joint, int width, int height, float skeletonMaxX, float skeletonMaxY)

            {

                SkeletonPoint pos = new SkeletonPoint()
                {
                    X = Scale(width, skeletonMaxX, joint.Position.X),
                    Y = Scale(height, skeletonMaxY, -joint.Position.Y),
                    Z = joint.Position.Z,
                   
                };
               
                Joint j = new Joint()
                {

                   JointType = joint.JointType,
                    TrackingState = joint.TrackingState,
                    Position = pos
                };


                return j;
            }

    I would appreciate some input

    Thaks

    Saturday, March 31, 2012 7:50 PM
  • Code it as follows:

    public static Joint ScaleTo(this Joint joint, int width, int height, float skeletonMaxX, float skeletonMaxY)
    {
        joint.Position = new SkeletonPoint()
        {
            X = Scale(width, skeletonMaxX, joint.Position.X),
            Y = Scale(height, skeletonMaxY, -joint.Position.Y),
            Z = joint.Position.Z,
        };
    
        return joint;
    }            
    

    John
    K4W Dev

    Sunday, April 1, 2012 6:02 AM
  • Hi John, I know this thread is few years back, but i'm trying to do the same thing, this time it's on SDK v1.8. I can't 'equate' the JointType. But this seem possible in SDK v2.0. Anyway to solve this?

    Here's the section of the code

    Joint currentJoint = new Joint();
    SkeletonPoint position = currentJoint.Position;
    currentJoint.TrackingState = JointTrackingState.NotTracked;
    position.X = -1;
    position.Y = -1;
    position.Z = -1;
    
    currentJoint.Position = position;
    currentJoint.JointType = JointType.AnkleLeft;
    
    if (_joint._jointType == "AnkleLeft")
        currentJoint.JointType = JointType.AnkleLeft;
    if (_joint._jointType == "AnkleRight")
        currentJoint.JointType = JointType.AnkleRight;
    if (_joint._jointType == "ElbowLeft")

    I can't get this line to work, it says JointType is read only.

    currentJoint.JointType = JointType.AnkleLeft;

    I try to modify like this, but still, failed.

    JointType cjoint = currentJoint.JointType;
    cjoint = JointType.AnkleLeft;
    currentJoint.JointType = cjoint;

    I really appreciates any help. Thank you so much!


    • Edited by late1010 Thursday, April 14, 2016 6:13 AM
    Thursday, April 14, 2016 6:13 AM