CvCapture_OpenNI2::CvCapture_OpenNI2 throws exception
System information (version)
- OpenCV => 4.1.1
- Operating System / Platform => Windows 10 64 Bit
- Compiler => Visual Studio 2017 (Working with QT)
Hello, I am trying to use Kinect SDK v1.8 with OpenNI2.2 + OpenCV 4.1.1 + QT. I can take images and videos from Kinect with my code. However, when I try the following code (attached in the file), I get an exception. Please do note that when building the OpenCV, I have marked WITH_OPENNI and WITH_OPENNI2 and added the required directory paths to cmake.
Throws the exception :
[ERROR:0] global C:\Users\username\Downloads\opencv-master\modules\videoio\src\cap.cpp (187) cv::VideoCapture::open VIDEOIO(OPENNI2): raised OpenCV exception:
OpenCV(4.1.1-pre) C:\Users\username\Downloads\opencv-master\modules\videoio\src\cap_openni2.cpp:275: error: (-2:Unspecified error) OpenCVKinect2: Device index exceeds the number of available OpenNI devices in function 'CvCapture_OpenNI2::CvCapture_OpenNI2'
The more interesting thing is, when I run this script twice, at first run, it throws exception, but on the second run, it registers the VideoCapture object and starts working. I really dont know what is the issue here but the reason I am trying to do this is that Kinect's sensors are not calibrated, so I am trying this piece of code. If this will not calibrate the sensors, any help about calibrating the RGB Cam and Depth Sensor is appreciated. Thanks in advance !