Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV can open only 3D cameras supporting the OpenNI library.

To open the camera, use:

VideoCapture cap(CV_CAP_OPENNI);

Then grab the images:

cap.grab();
cap.retrieve( depthMap, CV_CAP_OPENNI_DEPTH_MAP );

More information here: http://docs.opencv.org/2.4/doc/user_guide/ug_kinect.html

Otherwise use the default library to grab the images from the camera to a memory buffer, then convert it to Mat object. It should like something like:

ushort *buffer;
camera.grab(buffer);
Mat depthMap(camera.height,camera.width,CV_16U,buffer);

For object identification, you'll need to see how the images look like first, than try to find a solution for yourself first. Check this page for ideas: https://www.intorobotics.com/how-to-detect-and-track-object-with-opencv/

If you are looking for object identification from 3D point clouds, you can check the PCL library too.