Convert an image cv::Mat to QImage
I'm working on a project with Qt + OpenCV and I need to convert an image cv::Mat to QImage and / or viceversa. Does anyone know how to do?
Thanks in advance for any answers or comments.
If you are using one of the types supported by QImage, you can use the constructor taking an (const) uchar * input.
And the same in reverse, get the data from QImage with the bits function.
As the doc state, look carefully for the lifetime of your data.
http://qt-project.org/doc/qt-4.8/qimage.html#QImage-4 and its friends