Hi guys,
I need to convert a Mat to QImage for show a video in a label.
I’m using this code but my image is Mat and the code is Mat_double. I’m trying to do this:
Mat img;
Mat2QImage(img);
QImage Mat2QImage(const cv::Mat_<double> &src)
{
double scale = 255.0;
QImage dest(src.cols, src.rows, QImage::Format_ARGB32);
for (int y = 0; y < src.rows; ++y) {
const double *srcrow = src[y];
QRgb *destrow = (QRgb*)dest.scanLine(y);
for (int x = 0; x < src.cols; ++x) {
unsigned int color = srcrow[x] * scale;
destrow[x] = qRgba(color, color, color, 255);
}
}
return dest;
}
What can I do? Could I pass mat to mat_<double>?
[code wrappings added, koahnig]
↧