I need to capture the color RGB image from a Kinnect camera, but I want to show it in OpenCV as this is only a part of a bigger program. I know OpenCV has compatibility with OpenNI if you set the flag, but although I tried hard CMake couldn't find the path to OpenNI2 so I couldn't build OpenCV with OpenNI. Anyway I think it is good to know how to manually convert OpenNI frames to openCV frames, so I decided to follow this way.
For capturing the color frame in OpenNI I tried the following:
openni::Device device;
openni::VideoStream color;
openni::VideoFrameRef colorFrame;
rc = openni::OpenNI::initialize();
rc = device.open(openni::ANY_DEVICE);
rc = color.create(device, openni::SENSOR_COLOR);
rc = color.start();
color.readFrame(&colorFrame);
const openni::RGB888Pixel* imageBuffer = (const openni::RGB888Pixel*)colorFrame.getData();
But now I don't understand how to do the conversion to cv::Mat.
Does any anybody manged to do this?