How to take kinect video image and depth image with openCV c++?

后端 未结 3 663
谎友^
谎友^ 2020-12-29 12:47

I\'m new about opencv(c++) and kinect. I try to take a video image with c++ from kinect. I search everywhere but I didn\'t find anything. Because people are made using openN

3条回答
  •  半阙折子戏
    2020-12-29 13:19

    In case if someone is redirected here looking for a simpler method for visualizing the Kinect depth stream, I was able to do this in the following way for the KinectV2.

    Mat CDepthMap::getFrame()
    {
        IDepthFrame* frame;
        Mat depthImage;
        hr = _depth_reader->AcquireLatestFrame(&frame);
        if (SUCCEEDED(hr)) {
                const UINT imgSize = sDepthWidth*sDepthHeight; //512*424
                UINT16 pixelData[imgSize];
                hr = frame->CopyFrameDataToArray(imgSize, pixelData);
                if (SUCCEEDED(hr)) {
                depthImage = Mat(sDepthHeight,sDepthWidth, CV_8U);
                    for (UINT i = 0; i < imgSize; i++) {
                        UINT16 depth = pixelData[i];
                        depthImage.at(i) = LOWORD(depth);
                    }
            }
            SafeRelease(frame);
        }
        return depthImage;
    }
    

提交回复
热议问题