1
votes

I have installed OpenNI and SensorKinect following the tutorial here: and the example viewer works just fine. I have downloaded OpenCV 2.4.3 and then done the following:

  1. mkdir release
  2. cd release
  3. cmake-gui ..
  4. hit configure
  5. set WITH_OPENNI to ticked
  6. checked that it has found OPENNI dirs and primesense dir
  7. hit configure and then generate
  8. ran make

I then try and run the sample code from OpenCV-2.4.3/samples/openni_capture.cpp

However I get the following output:

Device opening ...
done.
Can not open a capture object.

The relevant code is:

VideoCapture capture(CV_CAP_OPENNI);
if( isVideoReading )
    capture.open( filename );
else
    capture.open( CV_CAP_OPENNI );

cout << "done." << endl;

if( !capture.isOpened() )
{
    cout << "Can not open a capture object." << endl;
    return -1;
}
2
just some obvious questions: is the kinect connected and also powered ? Have you tried it without the opencv/openni bindings (e.g. do the OpenNI samples run, etc.) ?George Profenza
@GeorgeProfenza Kinect is connected and powered. Yes, the openni samples run, I even compiled them myself and ran them. Just the openCV examples wontAly

2 Answers

0
votes

OK, I had the same problem.

I solved it by installing the SensorKinect driver again (something went wrong the first time) and then I installed OpenCV 2.4.3 like you described:

mkdir release
cd release
cmake-gui ..
hit configure
enabled WITH_OPENNI
hit configure and then generate
ran sudo make

I had to run make with sudo, otherwise I was getting errors all the time.

AND at the end you have to do

sudo make install

I mean, that's the meaning of the whole procedure above, isn't it? ;)

0
votes

Put this debugging line, cout << cv::getBuildInformation() << endl;, in your code, right before

if( !capture.isOpened() ) { cout << "Can not open a capture object." << endl; return -1; }

That will let you know if your opencv is installed with openni. If switches,

OpenNI: YES (ver 1.5.4, build 0) OpenNI PrimeSensor Modules: YES (/usr/lib/libXnCore.so)

are NO in your case, then you might want to consider recompiling your opencv modules with the cmake flag -D WITH_OPENNI=ON.

Cheers!