Ask Your Question
4

How to use Kinect with OpenCV?

asked Jul 29 '12

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?

Preview: (hide)

Comments

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 (Nov 16 '17)edit

1 answer

Sort by » oldest newest most voted
5

answered Jul 30 '12

updated Jul 30 '12

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);
for(;;)
{
    cv::Mat depthMap;
    cv::Mat rgbImage

    capture.grab();

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

    if( cv::waitKey( 30 ) >= 0 )
       break;
}

You can find more information here.

Preview: (hide)

Comments

3

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

Maria Dimashova gravatar imageMaria Dimashova (Jul 30 '12)edit

Question Tools

Stats

Asked: Jul 29 '12

Seen: 2,671 times

Last updated: Jul 30 '12