With the addition of OpenCV support for the Astra series of 3D depth cameras, it is possible to use cv::VideoCapture to obtain depth sensor information directly, the same process as using it to obtain a color camera video stream, greatly facilitating development.
VideoCapture depthStream(CAP_OPENNI2_ASTRA);// 打开深度视频流 depthStream.set(CAP_PROP_FRAME_WIDTH, 640);// 设置深度信息流的参数 depthStream.set(CAP_PROP_FRAME_HEIGHT, 480); depthStream.set(CAP_PROP_OPENNI2_MIRROR, 0);// 获取深度视频流Frame depthFrame; depthStream.grab(); depthStream.retrieve(depthFrame.frame, CAP_OPENNI_DEPTH_MAP);// 显示深度帧Mat depthMap = depthFrame.frame; Mat d8, dColor;depthMap.convertTo(d8, CV_8U, 255.0 / 2500); applyColorMap(d8, dColor, COLORMAP_OCEAN); imshow("Depth (colored)", dColor);
This tutorial is devoted to the Astra Series of Orbbec 3D cameras (https://orbbec3d.com/product-astra-pro/). That cameras have a depth sensor in addition to a common color sensor. The depth sensors can be read using the open source OpenNI API with cv::VideoCapture class. The video stream is provided through the regular camera interface.
In the sample images below you can see the color frame and the depth frame representing the same scene. Looking at the color frame it’s hard to distinguish plant leaves from leaves painted on a wall, but the depth data makes it easy.
The complete implementation can be found in orbbec_astra.cpp in