What is the easiest way to get the X, Y coordinates using C++ in SDK v1.0? RRS feed

  • Question

  • I have been reading the SDK v1.0 documentation for a few hours but cannot find any clue for getting the X, Y coordinates using C++.
    Are there any functions or sample code that show me the way to get these coordinates?

    Thank you very much.

    Friday, February 24, 2012 3:55 PM

All replies

  • Can you be more specific as to what it is you want to get the X and Y coordinates for?
    Friday, February 24, 2012 5:53 PM
  • Can you be more specific as to what it is you want to get the X and Y coordinates for?

    I would like to obtain the relative X, Y coordinate of some joints of a skeleton (i.e. left hand, right hand) and export them to csv file.
    Saturday, February 25, 2012 8:32 AM
  • I'm using the C++ Skeletal Viewer example from the SDK as a base, seems pretty straightforward and easy to follow.



    Tuesday, February 28, 2012 10:19 AM
  • As a side, I didn't end up using too much from the skeletal viewer, but have been playing around with the polling method - Im using the following, please ignore if a bit messy, but I only got my Kinect today (already have head tracking in my own 3d engine after a few hours playing around - gotta say the API is a breeze to implement)

    //Init the NUI specifying you want the skeleton

    //Poll this function once per frame - I've tried to simplify it as much as possible
    void Poll()

        NUI_SKELETON_FRAME SkeletonFrame = {0};
        if ( SUCCEEDED(NuiSkeletonGetNextFrame( 0, &SkeletonFrame )) )
            for ( int i = 0 ; i < NUI_SKELETON_COUNT ; i++ )
                if( SkeletonFrame.SkeletonData[i].eTrackingState == NUI_SKELETON_TRACKED ||
                    (SkeletonFrame.SkeletonData[i].eTrackingState == NUI_SKELETON_POSITION_ONLY))
    float x = SkeletonFrame.SkeletonData[i].SkeletonPositions[NUI_SKELETON_POSITION_HEAD].x;
    float x = SkeletonFrame.SkeletonData[i].SkeletonPositions[NUI_SKELETON_POSITION_HEAD].y;
    float z = SkeletonFrame.SkeletonData[i].SkeletonPositions[NUI_SKELETON_POSITION_HEAD].z;


    Hope this Helps
    Cheers Darrin

    Tuesday, February 28, 2012 1:21 PM
  • When eTrackingState == NUI_SKELETON_POSITION_ONLY, you'll find that there won't be usable values in the joints. You should only bother with the joints when eTrackingState == NUI_SKELETON_TRACKED.

    Also, before using a specific joint position such as the head, you'll probably want to check that SkeletonFrame.SkeletonData[i].eSkeletonPositionTrackingState[NUI_SKELETON_POSITION_HEAD] == NUI_SKELETON_POSITION_TRACKED (or possibly NUI_SKELETON_POSITION_INFERRED, depending on your needs).

    K4W Dev

    Wednesday, February 29, 2012 5:14 AM
  • IM doing this in for my project but if their was some code for some methods from help files I've seen to help with conversion from depth image to skeleton converted from beta2 to v1 i would use them because this is a way around your limitation john is to identify the correct person in depth then convert to skeleton.

    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda

    • Edited by The Thinker Wednesday, February 29, 2012 5:19 PM
    Wednesday, February 29, 2012 5:18 PM