Unsolved What format should I use to convert QImage to cv::Mat?
auto image = this->myLabel->pixmap()->toImage(); this->background = Mat(image.height(), image.width(), CV_8UC3, const_cast<uchar*>(image.bits()), static_cast<unsigned int>(image.bytesPerLine())).clone(); this->myLabel->setPixmap(mat2QPixmap(this->background, QImage::Format_RGB888));
This code does not seem to work.
I guess that this happens because I chose the incorrect format.
Yes could be wrong format.
Try code from here
Cant promise it works as i never used cv.
Are you sure your cv::Mat object contains RGB data ?
@SGaist As you can see, the data were extracted from the QImage
auto image = this->myLabel->pixmap()->toImage();
So it must be RGB data.
RGB, most likely, however it's likely not RGB888. You should check the format of your QImage object. As stated in the QPixmap::toImage documentation, it can be QImage::Format_ARGB32_Premultiplied for pixmaps with an alpha and QImage::Format_RGB32 or QImage::Format_RGB16 for pixmaps without alpha.