none
Get Co-Ordinate (XYZ) for C# RRS feed

  • Question

  • I'm beginning programmer and I have to do project that must get value of co-ordinate of each joint

    for beginning I just want to get xyz of only left hand that I tracking and save co ordinate to textfile. 

    From Titile "How to save XYZ-data to textfile?" it quite relate for my work and it's show me that just modify the nui_DepthFrameReady method to be:

     

    void nui_DepthFrameReady(object sender, ImageFrameReadyEventArgs e)

    {

      PlanarImage image = e.ImageFrame.Image;

     StreamWriter writer = new StreamWriter("myfile.txt");

      for (int i = 0; i < image.Bits.Length; i += 2)

      {

        int depthPixel = (image.Bits[i] << 8) | image.Bits[i];

        int x = (i/2) % 320; // Because image width is 320 pixels

        int y = (i/2) / 320;

         Microsoft.Research.Kinect.Nui.Vector realWorldPos = nui.SkeletonEngine.DepthImageToSkeleton(((float)x)/320.0f, ((float)y)/240.0f, depthPixel);

    writer.WriteLine(realWorldPos.X + " " + realWorldPos.Y + " " + realWorldPos.Z);

        // Store value of realWorldPos

    }

    }

     When I running program 3 second pass I got a lot of co-ordinate In the text file

    and that data that it's show it's got from every joint right ?

    and If I just want only one joint to show and get xyz. How can I do it? (Near Title How get the the joint x,y,z coordinates in C++)

    Thanks a lot for helper

    Chid

     

    Sunday, July 31, 2011 6:12 PM

Answers

  • Besides Susan's input (about looking at SkeletalViewer sample installed to C:\Users\Public\Documents\Microsoft Research KinectSDK Samples\NUI\SkeletalViewer\CS and seeing how they get skeleton joints rather than mapping depth pixels to skeleton points for what you need), the line of code that reads

    int depthPixel = (image.Bits[i] << 8) | image.Bits[i];

    should read

    int depthPixel = (image.Bits[i+1] << 8) | image.Bits[i];

    I made a mistake in my previous post to thread you referenced titled "How to save XYZ-data to textfile?". Very sorry about that.
    Eddy


    I'm here to help
    Tuesday, August 2, 2011 2:57 AM

All replies

  •  

    Hi Chid, 

     

    If this is a graded project you're probably expected to do your own work :) (Sorry! TA roots kicking in here! If this is not the case let us know and I'm sure you can get more detailed help.)

     

    Otherwise, I'd suggest looking at the SkeletonViewer sample code and tracing to exactly where they draw out the skeleton joints - this will give you the raw function calls to make to grab the joint information. (A hint, joint indices are enumerated values)

    Also, skeleton joint information is given in x,y,z coordinates, and in SkeletonViewer they convert them using an SDK function to depth image 2d space to draw them to the screen. 

    Also, in SkeletonViewer the application is constantly drawing and redrawing the skeleton joint information.   It sounds like you need to just take a single 'snapshot' of the joints at one moment in time.

    Finally, there is a help file for the different SDK functions available with the SDK installation "KinectSDK.chm" - you can locate it  under Program Files/Microsoft Research KinectSDK\docs (or Program File(x86) if you are on a Windows 7 machine).  Double click to run the CHM file and use the keywords/index to find the functions you're interested in.

    Good Luck!


    Susan
    Monday, August 1, 2011 11:52 AM
  • Besides Susan's input (about looking at SkeletalViewer sample installed to C:\Users\Public\Documents\Microsoft Research KinectSDK Samples\NUI\SkeletalViewer\CS and seeing how they get skeleton joints rather than mapping depth pixels to skeleton points for what you need), the line of code that reads

    int depthPixel = (image.Bits[i] << 8) | image.Bits[i];

    should read

    int depthPixel = (image.Bits[i+1] << 8) | image.Bits[i];

    I made a mistake in my previous post to thread you referenced titled "How to save XYZ-data to textfile?". Very sorry about that.
    Eddy


    I'm here to help
    Tuesday, August 2, 2011 2:57 AM