Depth sensors compatible with Intel Perceptual Computing SDK are supported through VideoCapture class. Depth map, BGR image and some other formats of output can be retrieved by using familiar interface of VideoCapture.
In order to use depth sensor with OpenCV you should do the following preliminary steps:
VideoCapture can retrieve the following data:
In order to get depth map from depth sensor use VideoCapture::operator >>, e. g.
VideoCapture capture( CV_CAP_INTELPERC );
for(;;)
{
Mat depthMap;
capture >> depthMap;
if( waitKey( 30 ) >= 0 )
break;
}
For getting several data maps use VideoCapture::grab and VideoCapture::retrieve, e.g.
VideoCapture capture(CV_CAP_INTELPERC);
for(;;)
{
Mat depthMap;
Mat image;
Mat irImage;
capture.grab();
capture.retrieve( depthMap, CV_CAP_INTELPERC_DEPTH_MAP );
capture.retrieve( image, CV_CAP_INTELPERC_IMAGE );
capture.retrieve( irImage, CV_CAP_INTELPERC_IR_MAP);
if( waitKey( 30 ) >= 0 )
break;
}
For setting and getting some property of sensor` data generators use VideoCapture::set and VideoCapture::get methods respectively, e.g.
VideoCapture capture( CV_CAP_INTELPERC );
capture.set( CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_PROFILE_IDX, 0 );
cout << "FPS " << capture.get( CV_CAP_INTELPERC_DEPTH_GENERATOR+CV_CAP_PROP_FPS ) << endl;
Since two types of sensor’s data generators are supported (image generator and depth generator), there are two flags that should be used to set/get property of the needed generator:
For more information please refer to the example of usage intelperc_capture.cpp in opencv/samples/cpp folder.