Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Mat to QPixmap

How can we convert directly cv::Mat to QPixmap without going through filename loading?

I have made some research about it but no hints!

As a first step, what I have tried is that I save the image, and then load it. But it's not what I want to have.

like image 732
user2354422 Avatar asked May 07 '13 13:05

user2354422


1 Answers

Jehan is right.

For people referring to this thread in the future: First convert image from BGR(used by OpenCV) to RGB.

Then:

QPixmap::fromImage(QImage((unsigned char*) mat.data, mat.cols, mat.rows, QImage::Format_RGB888));
like image 114
mehfoos yacoob Avatar answered Sep 17 '22 23:09

mehfoos yacoob