VideoCapture capture( CV_CAP_OPENNI );
sounds like your using OpenCV built with OpenNI support. I recommend installing OpenNI first. Version 1.5.4.0 which you can find here works with OpenCV. I haven't tested OpenNI 2.0 with OpenCV yet.
You need to install 3 things in this order:
- OpenNI
- NITE
- Sensor Kinect (Avin's driver has the patch for Kinect, where as the default Sensor Driver is for Asus like sensors)
Once you've installed OpenNI and it works: PrimeSense drivers detects the device and you can run any of the OpenNI samples, like NiViewer
(in OpenNIInstallFolder/Samples/Build/Bin/..etc.)
you can choose to simple use the C++ OpenNI API or install and use OpenCV with OpenNI support.
You should built it from source and using CMake turn OpenNI support on.
Once that's built OpenCV with OpenNI support you can run the above code.
Here's a screenshot running ccmake
. It should very similar on Windows with CMake.
You don't need all the other settings exactly like mine, make sure WITH_OPENNI
is ON
.
I've recently posted an OpenCV/OpenNI simple filtering example here.