Search code examples
c++qtkinectkinect-sdk

How to pass a kinect image frame to a Qt label?


I'm using the Kinect SDK and Qt toolkit to make a application that shows the depth frame in a GUI window. For a normal opencv camera image i use to do this:

qimage = QImage(image.data, 640, 480, QImage::Format_Indexed8);
    pixmap = QPixmap::fromImage(qimage);
    ui.DepthView->adjustSize();

But with the Kinect sdk this doesn't work. When i grab a frame like this:

hr = m_pNuiSensor->NuiImageStreamGetNextFrame(m_pDepthStreamHandle, 
1000, &imageFrame);

I can't convert it to an Qimage. I also tryed to use the texture after grabbing the frame:

hr = m_pNuiSensor->NuiImageFrameGetDepthImagePixelFrameTexture(m_pDepthStreamHandle,
&imageFrame, &nearMode, &pTexture);

And then i tryed to convert the pTexture to a Qimage, but that doesn't work either.

I cleary do something wrong here, can anybody give me some pointers with this?

Thanks in advance!


Solution

  • Is the value of image.data preserved? It must remain valid until the QImage is no longer in use...