How to draw the skeleton from the available coordinates ? RRS feed

  • Question

  • Hi everyone, as i typed in the question, i want to draw the skeletons-line (or draw the line between two points ) from the available coordinates. After drawing, the completed manual-skeleton will look like this. It draw as same as Skeleton Basic did, but the coordinates provided by us.

    I saved the coordinates of joints in a text file and this application will take the data from this file to draw. Can anyone please help me ? I really need it.

    Sorry for my bad english!
    • Edited by Phuc Truong Saturday, March 1, 2014 1:57 PM
    Friday, February 28, 2014 3:44 PM

All replies

  • Once you have received the data from the Kinect, there are no further api's provided by the SDK that will draw or read the data from other sources. If you are reading the data from a file, then you can do something that is similar to how that is done with the sample.

    Otherwise, there are other threads that discuss doing this, maybe these will help you.

    Carmine Sirignano - MSFT

    Friday, February 28, 2014 8:54 PM
  • Thanks, I did the same as he typed, but i didn't work :( the skeleton was wrong and it didn't move, can you review it and fix the problem for me ?

    FileStream fs;
            private void Model_DrawBoneAndJoints(ref Skeleton skeleton, DrawingContext drawingContext)
                fs = new FileStream
                    (@"C:\Users\PhucTruongTien\Desktop\datagram.txt", FileMode.Open, FileAccess.Read, FileShare.None);
                StreamReader sr = new StreamReader(fs);
                float[] x = new float[20];
                float[] y = new float[20];
                SkeletonPoint position;
                Array Joint_Types = Enum.GetValues(typeof(JointType));
                //Joint[] joint_array = new Joint[20];
                foreach (JointType j_types in Joint_Types)
                    Joint joint = new Joint();
                    joint = skeleton.Joints[j_types];
                    joint.TrackingState = JointTrackingState.Tracked;
                    position = joint.Position;
                    position.X = (float)Convert.ToDouble(sr.ReadLine());
                    position.Y = (float)Convert.ToDouble(sr.ReadLine());
                    position.Z = (float)Convert.ToDouble(sr.ReadLine());
                    joint.Position = position;
                    skeleton.Joints[j_types] = joint;
    private void DrawBonesAndJoints(Skeleton skeleton, DrawingContext drawingContext)
                //DetectJoints(skeleton, i);
                Model_DrawBoneAndJoints(ref skeleton, drawingContext);
                // Render Torso
                this.DrawBone(skeleton, drawingContext, JointType.Head, JointType.ShoulderCenter);
                this.DrawBone(skeleton, drawingContext, JointType.ShoulderCenter, JointType.ShoulderLeft);
                this.DrawBone(skeleton, drawingContext, JointType.ShoulderCenter, JointType.ShoulderRight);
                this.DrawBone(skeleton, drawingContext, JointType.ShoulderCenter, JointType.Spine);
                this.DrawBone(skeleton, drawingContext, JointType.Spine, JointType.HipCenter);
                this.DrawBone(skeleton, drawingContext, JointType.HipCenter, JointType.HipLeft);
                this.DrawBone(skeleton, drawingContext, JointType.HipCenter, JointType.HipRight);
                // Left Arm
                this.DrawBone(skeleton, drawingContext, JointType.ShoulderLeft, JointType.ElbowLeft);
                this.DrawBone(skeleton, drawingContext, JointType.ElbowLeft, JointType.WristLeft);
                this.DrawBone(skeleton, drawingContext, JointType.WristLeft, JointType.HandLeft);
                // Right Arm
                this.DrawBone(skeleton, drawingContext, JointType.ShoulderRight, JointType.ElbowRight);
                this.DrawBone(skeleton, drawingContext, JointType.ElbowRight, JointType.WristRight);
                this.DrawBone(skeleton, drawingContext, JointType.WristRight, JointType.HandRight);
                // Left Leg
                this.DrawBone(skeleton, drawingContext, JointType.HipLeft, JointType.KneeLeft);
                this.DrawBone(skeleton, drawingContext, JointType.KneeLeft, JointType.AnkleLeft);
                this.DrawBone(skeleton, drawingContext, JointType.AnkleLeft, JointType.FootLeft);
                // Right Leg
                this.DrawBone(skeleton, drawingContext, JointType.HipRight, JointType.KneeRight);
                this.DrawBone(skeleton, drawingContext, JointType.KneeRight, JointType.AnkleRight);
                this.DrawBone(skeleton, drawingContext, JointType.AnkleRight, JointType.FootRight);
                // Render Joints
                foreach (Joint joint in skeleton.Joints)
                    Brush drawBrush = null;
                    if (joint.TrackingState == JointTrackingState.Tracked)
                        drawBrush = this.trackedJointBrush;
                    else if (joint.TrackingState == JointTrackingState.Inferred)
                        drawBrush = this.inferredJointBrush;
                    if (drawBrush != null)
                        drawingContext.DrawEllipse(drawBrush, null, this.SkeletonPointToScreen(joint.Position), JointThickness, JointThickness);

    Saturday, March 1, 2014 11:28 AM
  • you have to build the skeleton structure from the file before you can draw anything. How is the order your functions are being executed? If you print the values to the console, do they match what you captured?

    Carmine Sirignano - MSFT

    Monday, March 3, 2014 9:53 PM