none
How to save Joint Positions (x y z) in SDK v2 ? RRS feed

  • Question

  • Hey Everybody,

    I´d like to save the  joint positions to a *.txt file in SDK v2.

    I had a code in SDK 1.8, can anybody help me out how to change it (or provide a hint) how to do this in SDK 2.0)?

    This is the snipplet out of SDK 1.8 how i saved the positions to a string: i used a start button and stopped after 1800 captured frames. After that i´ve written the string into a txt file.

    [code]

                        if (aufzeichnen == 1) { Info.Text = "Aufzeichnung läuft \r\n Anzahl Datensätze:" + 
    Capture_Daten.Count.ToString("0"); }
                        if (aufzeichnen == 0) { Info.Text = "Aufzeichnung gestoppt \r\n Anzahl Datensätze:" +   Capture_Daten.Count.ToString("0"); }

                        string Datenzeile = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff") + " "

                          + Head.Position.X.ToString("0.00") + " " + Head.Position.Y.ToString("0.00") + " " + Head.Position.Z.ToString("0.00") + " "
                         + ShoulderCenter.Position.X.ToString("0.00") + " " + ShoulderCenter.Position.Y.ToString("0.00") + " " + ShoulderCenter.Position.Z.ToString("0.00") + " "
                          + Spine.Position.X.ToString("0.00") + " " + Spine.Position.Y.ToString("0.00") + " " + Spine.Position.Z.ToString("0.00") + " "
                          + HipCenter.Position.X.ToString("0.00") + " " + HipCenter.Position.Y.ToString("0.00") + " " + HipCenter.Position.Z.ToString("0.00");

                        if (aufzeichnen == 1)
                        {
                            Capture_Daten.Add(Datenzeile);

                            if (Capture_Daten.Count == 1800)
                            {
                                aufzeichnen = 0;
                            }
                        }
    [/code]

    For SDK v2 i used the BodyBasics-WPF as a start, do have a working button to save a txt file, have seen how to draw the joints, but how can i access the Joint positions to save them (as a string so i can write them to a *.txt file)?                  

    Thanks for any help,

    best regards,

    Dominik




    Monday, October 20, 2014 3:50 PM

Answers

  • The camera is 0,0,0

    Distance is in Meters. 

     

      X -0.00375599787 float (right of the center line of  camera is positive)
      Y 0.866948545 float (above of the center line of  camera is positive)
      Z 0.498383552 float distance from the front of the camera

    You need to do a transform to get it to "real space" use the BodyFrame .FloorClipPlane   gives a Vector4 element (X,Y,Z,W) vector and do the dot product or some basic trig functions to transform the Y & Z into (1,0,0) X plane.

    https://social.msdn.microsoft.com/Forums/en-US/594cf9ed-3fa6-4700-872c-68054cac5bf0/angle-of-kinect-device-and-effect-on-xyz-positional-data?forum=kinectv2sdk


    Ken

    • Marked as answer by Dominik Bonin Wednesday, October 22, 2014 2:28 PM
    Wednesday, October 22, 2014 2:18 PM
  • joint/body data is a CameraSpacePoint which is in meters. It is a 3D position based on the location of the depth camera, where z is point away from the sensor in a positive direction.

    Carmine Sirignano - MSFT

    • Marked as answer by Dominik Bonin Wednesday, October 22, 2014 2:28 PM
    Wednesday, October 22, 2014 2:25 PM
  • I don't know C++, but here's the C#. 

    It comes from the BodyFrame object, you have to 

    Vector4 floorClipPlane = new Vector4(); ....

        private void Reader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
        BodyFrameReference frameReference = e.FrameReference;

    BodyFrame frame = frameReference.AcquireFrame(); if (frame != null) { floorClipPlane = frame.FloorClipPlane;

    "degrees angle=" + Math.Round(Math.Atan(floorClipPlane.Z / floorClipPlane.Y) * 180 / Math.PI, 4)


    Ken

    • Marked as answer by Dominik Bonin Wednesday, January 14, 2015 9:07 AM
    Tuesday, January 13, 2015 7:38 PM

All replies

  • joint data is part of a Joints Collection on the body object.

    http://msdn.microsoft.com/en-us/library/windowspreview.kinect.body.joints.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1


    Carmine Sirignano - MSFT

    Tuesday, October 21, 2014 5:41 PM
  • Thank you very much for your reply!

    What i did now is: within the bodyFrame section i defined the joints
    e.g. Joint Neck = body.Joints[JointType.Neck];

    and then by klicking a start-stop button added the

    float Neck_x = Neck.Postion.X;

    float Neck_y = Neck.Position.Y;

    float Neck_Z = Neck.Position.Z;

    framewise to an ArrayList, which i could write into a text file.

    Further Question:

    I now have the X, Y, Z position of each Joint for each captured frame in mm. But i do have a Problem with interpreting the data, what exactly do i measure there? What is the point of origin?

    Wednesday, October 22, 2014 12:54 PM
  • The camera is 0,0,0

    Distance is in Meters. 

     

      X -0.00375599787 float (right of the center line of  camera is positive)
      Y 0.866948545 float (above of the center line of  camera is positive)
      Z 0.498383552 float distance from the front of the camera

    You need to do a transform to get it to "real space" use the BodyFrame .FloorClipPlane   gives a Vector4 element (X,Y,Z,W) vector and do the dot product or some basic trig functions to transform the Y & Z into (1,0,0) X plane.

    https://social.msdn.microsoft.com/Forums/en-US/594cf9ed-3fa6-4700-872c-68054cac5bf0/angle-of-kinect-device-and-effect-on-xyz-positional-data?forum=kinectv2sdk


    Ken

    • Marked as answer by Dominik Bonin Wednesday, October 22, 2014 2:28 PM
    Wednesday, October 22, 2014 2:18 PM
  • joint/body data is a CameraSpacePoint which is in meters. It is a 3D position based on the location of the depth camera, where z is point away from the sensor in a positive direction.

    Carmine Sirignano - MSFT

    • Marked as answer by Dominik Bonin Wednesday, October 22, 2014 2:28 PM
    Wednesday, October 22, 2014 2:25 PM
  • Dear Ken,

    i´m struggeling with the implementation of the floorClipPlane. Can you please tell me how i have to define or initialize the vector4 element? Where in my code i will have to place it?

    Thanks in advance,

    Dominik

    Tuesday, January 13, 2015 2:31 PM
  • I'd also like to know that!

    Vector4 clipPlane = IBodyFrame::get_FloorClipPlane;

    doesn't work...

    Tuesday, January 13, 2015 3:35 PM
  • I don't know C++, but here's the C#. 

    It comes from the BodyFrame object, you have to 

    Vector4 floorClipPlane = new Vector4(); ....

        private void Reader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
        BodyFrameReference frameReference = e.FrameReference;

    BodyFrame frame = frameReference.AcquireFrame(); if (frame != null) { floorClipPlane = frame.FloorClipPlane;

    "degrees angle=" + Math.Round(Math.Atan(floorClipPlane.Z / floorClipPlane.Y) * 180 / Math.PI, 4)


    Ken

    • Marked as answer by Dominik Bonin Wednesday, January 14, 2015 9:07 AM
    Tuesday, January 13, 2015 7:38 PM
  • This works great, the sensor height and angle now show reasonable values and i can start with my transformation. Thank you very much !!

    Wednesday, January 14, 2015 9:25 AM
  • Hi Dominik, 

    currently, I am doing a research project for my bachelor thesis with the Kinect V2. Now I wanted to evaluate my algorithm by checking the joint coordinates of multiple frames. To do this I would like to save the joint positions to a .txt file in SDK V2 and pass them to an excel file later on.

    So I wanted to ask you if you would be so kind and share your V2 code. That would be of great help.

    Best regards,

    Hao

    Saturday, February 25, 2017 6:52 PM
  • Hey Hao,

    its now a long time ago since i´ve coded my project, but i remember i ended up using this code from MyriamDS to export the data to a *.csv file:

    https://gist.github.com/MyriamDS/7767373

    Good Luck with your bachelor thesis,

    Best Regards, Dominik

    Friday, March 3, 2017 9:03 AM