Ask Your Question

How to use Kinect with OpenCV?

asked 2012-07-29 00:44:34 -0500

Kirill Kornyakov gravatar image

I want to get depth and color images from Kinect, how can I do this? Is there any tutorial or code sample?

edit retag flag offensive close merge delete


There is the Kinect SDK versions 1.x and 2.x. It comes with C# and C++ code, I believe. This way you control the Kinect yourself, and don't have to build OpenCV with OpenNI support.

sjhalayka gravatar imagesjhalayka ( 2017-11-16 13:27:38 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2012-07-30 03:37:53 -0500

updated 2012-07-30 05:51:47 -0500

You can enable OpenNI when building OpenCV from sources, by checking the WITH_OPENNI CMake option. Then, in your code :

cv::VideoCapture capture(CV_CAP_OPENNI);
    cv::Mat depthMap;
    cv::Mat rgbImage


    capture.retrieve( depthMap, OPENNI_DEPTH_MAP );
    capture.retrieve( bgrImage, OPENNI_BGR_IMAGE );

    if( cv::waitKey( 30 ) >= 0 )

You can find more information here.

edit flag offensive delete link more



There is also a sample 'samples/cpp/openni_capture.cpp'

Maria Dimashova gravatar imageMaria Dimashova ( 2012-07-30 05:35:14 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2012-07-29 00:44:34 -0500

Seen: 2,103 times

Last updated: Jul 30 '12