OpenCV 2.4.9 + Asus Xtion Pro Live

asked 2014-11-24 04:09:46 -0500

tobi gravatar image

I'm trying to use a Xtion Pro Live Sensor with opencv ver. 2.4.9 for processing images. I'm using Visual Studio 2010 on Win7 64 Bit, however i'm building 32 Bit projects on VC2010 (Can I do this with the Asus Camera or do I need to use 64 Bit applications?). I installed the drivers on the CD (Primesense,Nite, OpenNI 1.5.4) and the Xtion Pro Live is also shown in the device manager as "Primesense 1080". Using the sample "NiSimpleViewer" works, however when I'm using my own code with opencv (Code below), I cant get a connection to the sensor (returns NULL).

include "cv.h"

include "highgui.h"

include "iostream"

include "stdio.h"

using namespace cv; using namespace std;

int main(){

CvCapture* capture = cvCaptureFromCAM(CV_CAP_OPENNI_ASUS);
CvCapture* test = cvCreateCameraCapture(CV_CAP_OPENNI_ASUS);
for(int i=0; i<1000;i++){
VideoCapture cap(i);
    printf("Device opened");
    int save = i;

if (capture){
    cout<<"Device opened";

cvReleaseCapture( &capture );
cvDestroyWindow( "Example" );


As you can see, I also tried with a for loop, to check all possibilities (as -1 and 0 didn't work).

edit retag flag offensive close merge delete


When you built opencv, did you set the -WITH_OPENNI flag? I had a similar problem when I didn't know that. If not you have to build it again with the right flags set.

It could also be a problem with your openni/primesense version. But since you can launch the viewer that shouldn't be it.

mike_s_ gravatar imagemike_s_ ( 2014-11-25 02:55:15 -0500 )edit