black frame on the depth map with Kineсt (Bug #2902)
Description
This code displays the depth map, which is always present black border at the top and on the right images, to RGB image this area appears correctly. Distance to objects in the field correct. Used OpenCV 2.4 and OpenNI 1.5.4. With examples in OpenNI depth map displayed correctly.
#include <iostream> #include <opencv2/core/core.hpp> #include <opencv2/features2d/features2d.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/calib3d/calib3d.hpp> int main() { cv::VideoCapture cap(CV_CAP_OPENNI); cv::namedWindow("depth", 1); cv::namedWindow("bgr", 1); cv::Mat depthMap; cv::Mat bgrImage; cap.grab(); cap.retrieve( depthMap, CV_16UC1 ); cap.retrieve( bgrImage, CV_32FC1 ); cv::Mat gray; cv::cvtColor(bgrImage, gray, CV_BGR2GRAY); while(1) { cap.grab(); cap.retrieve( depthMap, CV_16UC1 ); cap.retrieve( bgrImage, CV_32FC1 ); cv::Mat tmp; cv::cvtColor(depthMap, tmp, CV_GRAY2BGR); cv::threshold(depthMap, depthMap, 60, 255, cv::THRESH_BINARY); cv::imshow("depth", tmp); cv::imshow("bgr", bgrImage); if( cv::waitKey( 20 ) >= 0 ) break; } return 0; }
History
Updated by Daniil Osokin almost 12 years ago
Sergei, thanks for attention!
- Category set to calibration, 3d
- Priority changed from High to Normal
- Target version set to 3.0
Updated by Daniil Osokin almost 12 years ago
- Assignee set to Vadim Pisarevsky
Updated by Rafael Saracchini over 11 years ago
I can confirm this issue with the current version of OpenCV (2.4.6) using a Kinect For Windows in Debian Wheezy. Images retrieved with libfreenect and NiViewer from OpenNI do not have such border.
Updated by Victor Kocheganov over 11 years ago
- HW Platform set to Any
- Operating System set to Linux
- Affected version changed from branch 'master' (2.4.9) to 2.4.6 (latest release)
- Assignee changed from Vadim Pisarevsky to Ilya Lysenkov
Updated by Ilya Lysenkov over 11 years ago
Hi,
Thanks for the report. Indeed, it looks unexpected but actually it is not a bug, it is the correct behaviour. It originates from the fact that depth images are transformed into the coordinate system of the RGB camera. These cameras have different filed of views and locations and so there are areas which were seen by the RGB camera but not observed by the depth camera. These areas appear as black in a depth image.
If you want to get the original depth image you need to set CV_CAP_PROP_OPENNI_REGISTRATION to 'off' (see the user guide and the openni_capture.cpp sample).
- Category changed from calibration, 3d to highgui-camera
- Status changed from Open to Cancelled