Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If you have compiled OpenCV with OpenNI, and the RGBD camera which you use is supported (i.e. Kinect/Asus), then you can use the cv::VideoCapture class to obtain RGBD data.

For example:

 cv::VideoCapture videoReader;
 videoReader.open( CV_CAP_OPENNI );
 //Set capture to 640x480 images at 30Hz 
 videoReader.set( CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE, CV_CAP_OPENNI_VGA_30HZ );
 //Grabs current frame
 videoReader.grab();
 //retrieves RGB,Depth and mask data
 cv::Mat  rgbImg,dptImg,mskImg;
 videoReader.retrieve(rgbImg,CV_CAP_OPENNI_BGR_IMAGE );
 videoReader.retrieve(dptImg,CV_CAP_OPENNI_DEPTH_MAP);
 videoReader.retrieve(mskImg,CV_CAP_OPENNI_VALID_DEPTH_MASK);

See the openni example in the examples folder that come with OpenCV source code.