Madiha Salafi
Madiha Salafi

Reputation: 21

How to get raw depth values from Kinect depth stream?

I am tracking the motion of a human body using Lucas Kanade algorithm. I am working on RGB and Depth streams of Kinect. I have to place some points on the body, and track those points. Finally their xyz co-ordinates have to be calculated.

My question is, how to get z coordinate for a particular pixel from the depth stream? I know Depth raw depth values for kinect lie in 0-2047 range..and applying formulas on it can get me the distance in any units I want. But how to get this raw depth? Can anyone help?

I am using libfreenect driver for kinect and opencv.

Upvotes: 2

Views: 2408

Answers (1)

Ian Medeiros
Ian Medeiros

Reputation: 1776

With OpenCV 2.3.x, you can retrieve all the information that you want. You will need to compile it from source with OpenNI to work. Look at this code:

VideoCapture capture(CV_CAP_OPENNI); 
for(;;)
{
    Mat depthMap;
    Mat rgbImage

    capture.grab();

    capture.retrieve( depthMap, OPENNI_DEPTH_MAP );



    if( waitKey( 30 ) >= 0 )
        break;
}

Yes, its that easy. depthMap will store a depth in each index. This depth represents the distance from the sensor to the surface were the depth has been measured with the IR. More details at: http://opencv.itseez.com/doc/user_guide/ug_highgui.html

Upvotes: 3

Related Questions