none
draw a skeleton from points stored in file RRS feed

  • Question

  • Hello, 

    i save the joints of a skeleton in a txt file like this

    this file has the 20 point of the skeleton, i need to load and draw again without kinect but 

    i try this code(to begin not from the file just for test) but doesnot work 

    can help me?

     Skeleton skeleton = new Skeleton();
               SkeletonPoint position;
               Joint joint = skelp.Joints[JointType.HipCenter];
               joint.TrackingState = JointTrackingState.Tracked;
               position.X = 0.1965346F;
               position.Y = 0.2214949F;
               position.Z = 2.042568F;
                joint.Position = position;
                skeleton.Joints[JointType.HipCenter] = joint;

     -0.07725279,0.09287128,3.028855
     -0.07509108,0.1540889,3.09081
     -0.07656983,0.5319178,3.118125
     -0.0941205,0.7023382,3.104022
     -0.2401868,0.4237205,3.069376
     -0.3958119,0.2669458,3.043052
     -0.5133927,0.1157001,2.984091
     -0.558727,0.07181259,2.965935
     0.05349273,0.4075375,3.053571
     0.218326,0.2477966,3.012332
     0.3375109,0.09916961,2.949077
     0.3980893,0.04431406,2.942766
     -0.1427073,0.02814272,3.009981
     -0.1578576,-0.3028181,3.016551
     -0.1811096,-0.5142938,3.092035
     -0.1952398,-0.5939106,3.059329
     -0.01203542,0.0286103,3.017139
     0.001478896,-0.2914025,3.006021
     0.02289137,-0.5053569,3.050208
     0.02811828,-0.5722635,2.994491

    Wednesday, October 16, 2013 4:03 PM

Answers

All replies

  • What is not working? Did you forget to overwrite the previous value in the Joint/Skeleton?

    public void CreateSkeleton(ref Skeleton skeleton)
    {
        if (skeleton == null)
        {
            skeleton = new Skeleton();
        }
    
        Array jointTypes = Enum.GetValues(typeof(JointType));
        SkeletonPoint position;
        Joint joint;
        foreach (JointType type in jointTypes)
        {
            joint = skeleton.Joints[type];
                    
            // set state
            joint.TrackingState = JointTrackingState.Tracked;
    
            position = joint.Position;
            position.X = 1.0f;
            position.Y = 1.0f;
            position.Z = 1.0f;
    
            // set position
            joint.Position = position;
    
            // put joint back into skeleton
            skeleton.Joints[joint.JointType] = joint;
        }
    }
    

    http://social.msdn.microsoft.com/Forums/en-US/eb0074c4-358f-4b4c-b2dd-16cfe9b64861/how-to-create-my-own-joint-object-as-the-jointtype-is-internal-set-sdk-10?forum=kinectsdknuiapi


    Carmine Sirignano - MSFT

    Wednesday, October 16, 2013 11:28 PM
  • Thanks a lot  your answer is really helpful for me i have some mistakes

    then I had another problem, as I was putting the data manually and give me this error

    DepthImagePoint depthPoint = this.sensor.CoordinateMapper.MapSkeletonPointToDepthPoint(skelpoint, DepthImageFormat.Resolution640x480Fps30);

    but was for the kinect have to be connected, so the problem is solved

    THANKS A LOT


    Monday, October 21, 2013 4:33 PM
  • I did the same as you 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);
    
    
                //i++;
                // 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:26 AM