Kinect highGUI configuration problem?

asked 2014-06-18 08:14:17 -0600

klemen gravatar image

Dear all,

I am trying to obtain the point cloud and color stream from Kinect device. I have followed the instructions here (http://docs.opencv.org/doc/user_guide/ug_highgui.html) but am unable to open the data stream from the device (via VideoCapture capture( CV_CAP_OPENNI )).

The examples in OpenNI folders work and I have been using the Kinect in the past with the PCL library. The reason I need to get this working is because the Mat type in OpenCV is much easier to use than the point cloud type in PCL (at least for me, since I need to pass the data via the .dll).

At the end of the post is the relevant Cmake folder configuration, where the OpenNI and Prime Sense path seems ok to me. Versions: - OpenNI 1.5.4 - OpenCV 2.4.6 - Prime Sense 5.1.0.41

It is strange that I have not found the Prime Sense nor OpenNI status in the Cmake log after building OpenCV with OpenNI. The code I am using is simple:

#include "opencv2/highgui/highgui.hpp"

using namespace cv; using namespace std;

int main() { VideoCapture sensor(CV_CAP_OPENNI);

if( !sensor.isOpened() ){        
    return -1;
}

for(;;){
    Mat depth;

    if( !sensor.grab() ){           
        return -1;
    }
    else if( sensor.retrieve( depth, CV_CAP_OPENNI_DEPTH_MAP ) ) 
    imshow("depth",depth);

    if( waitKey( 30 ) == 27 )   break;

} }

If I replace the "CV_CAP_OPENNI" with "0" I can get the stream from my integrated webcamera.

Can anybody help me please?

In addition I have another question: is it possible to open the camera stream and leave it open (for example with some function "INIT"), so that for each call to the .dll function (for example "GET DATA") I can get the data from the camera

THE PATHS FOR OPENNI AND PRIME SENSE AS CONFIGURED BY CMAKE:

//OpenNI c++ interface header OPENNI_INCLUDES:FILEPATH=C:/Program Files (x86)/OpenNI/Include/XnCppWrapper.h

//Path to OpenNI headers OPENNI_INCLUDE_DIR:PATH=C:/Program Files (x86)/OpenNI/Include

//OpenNI library OPENNI_LIBRARY:FILEPATH=C:/Program Files (x86)/OpenNI/Lib/openNI.lib

//Path to OpenNI libraries OPENNI_LIB_DIR:PATH=C:/Program Files (x86)/OpenNI/Lib

//Core library of PrimeSensor Modules for OpenNI OPENNI_PRIME_SENSOR_MODULE:FILEPATH=C:/Program Files (x86)/PrimeSense/Sensor/Bin/XnCore.dll

//Path to OpenNI PrimeSensor Module binaries OPENNI_PRIME_SENSOR_MODULE_BIN_DIR:PATH=C:/Program Files (x86)/PrimeSense/Sensor/Bin

Thank you very much and best regards, K

edit retag flag offensive close merge delete

Comments

1

Did you check the WITH_OPENNI in the build options?

Otherwise I think OpenNI 1.5 is outdated. I suggest to use OpenNI 2.2 (without OpenCV) and to transform the captured data to cv::Mat structure. Here is how to do it:

http://answers.opencv.org/question/33513/opencv-asus-xtion-sensor/

kbarni gravatar imagekbarni ( 2014-06-19 11:02:42 -0600 )edit