1
votes

I'm using the Kinect for Windows SDK (v1.8) I'm successfully reading motion from the Kinect but I'm now wondering how to get the absolute position of the joint I'm tracking (right hand)

I'm using the following function, NuiTransformSkeletonToDepthImage, but the values range from 100-200 in both x and y coordinates.

Any suggestions for how to transform the returned coordinates to screen coordinates? Got a feeling I'm missing something really obvious though...

Thank you in advance

1

1 Answers

0
votes

Ok, after quite a bit of looking around and trial and error; I found the solution.

When you call NuiTransformSkeletonToDepthImage(); you can specify a Kinect resolution using the NUI_IMAGE_RESOLUTION enum. I believe the values are; 80x60, 320x240, 640x480, 1280x960

Depending on what resolution you decide to use; you'll need to divide the returned x and y coords by the corresponding resolution. Then multiply those by your window size and you should have the coordinates in your window.

I believe you can also specify the resolution when creating an instance of the Kinect Sensor interface.

Example as my explanation isn't too concise:

float x, y
const Vector4 fromPos = skeleton.SkeletonPositions[NUI_SKELETON_POSITION_HAND_RIGHT];
NuiTransformSkeletonToDepthImage(fromPos, &x, &y, NUI_IMAGE_RESOLUTION_320x240);
x = x * ((float)WINDOW_WIDTH / 320.0f);
y = y * ((float)WINDOW_HEIGHT / 240.0f);

Any questions; feel free to ask.