how to get the 3D data of any point in the kinect image?(c++) RRS feed

  • Question

  • We can get the 3D data of a human's joint by Kinect but how can I get 3D data of any point in the Kinect view?(c++)
    Wednesday, August 29, 2012 11:42 AM

All replies

  • Are you asking about the depth data? Have you looked at the various Depth samples in the Developer Toolkit 1.51?
    Friday, August 31, 2012 12:28 AM
  • um.I have read some of them.
    Sunday, September 9, 2012 3:40 AM
  • By "any point in the Kinect view", I assume you mean "any pixel in an image captured by Kinect." Assuming that's what you mean, the function you want is NuiTransformDepthImageToSkeleton. The word "Skeleton" here is an unfortunate misnomer; it merely means "a point expressed in same coordinate system as skeletons." The function can be used even by applications that do not use the skeleton tracking feature.

    Assuming you already have a depth stream opened, try the following code:

    NUI_IMAGE_FRAME imageFrame;
    if (SUCCEEDED(pNuiSensor->NuiImageStreamGetNextFrame(
        NUI_LOCKED_RECT lockedRect;
        if (SUCCEEDED(imageFrame.pFrameTexture->LockRect(0, &lockedRect, nullptr, 0)))
            LONG xPixel = /* x pixel coordinate */;
            LONG yPixel = /* y pixel coordinate */;
            USHORT depthData = lockedRect.pBits[yPixel * lockedRect.Pitch * sizeof(USHORT) + xPixel];
            Vector4 point = NuiTransformDepthImageToSkeleton(xPixel, yPixel, depthData, imageFrame.eResolution);
            /* point.x, point.y, and point.z are the coordinates (in meters) of the object at xPixel, yPixel in the depth camera */

    John | K4W Dev

    Tuesday, September 11, 2012 5:15 PM