QT QImage to cv::Mat conversion causing memory leak
-
I have a QPixmap which I want to convert to cv::Mat. First I've converted it to QImage.
QPixmap picture; QImage image = picture.toImage();Then the QImage is sent to the conversion function. But this function is causing memory leak.
cv::Mat QImage2Mat(const QImage& src) { cv::Mat mat = cv::Mat(src.height(), src.width(), CV_8UC4, (uchar*)src.bits(), src.bytesPerLine()); cv::Mat result = cv::Mat(mat.rows, mat.cols, CV_8UC3 ); int from_to[] = { 0,0, 1,1, 2,2 }; cv::mixChannels( &mat, 1, &result, 1, from_to, 3 ); return result; }cv::Mat matImage = QImage2Mat(image); -
I have a QPixmap which I want to convert to cv::Mat. First I've converted it to QImage.
QPixmap picture; QImage image = picture.toImage();Then the QImage is sent to the conversion function. But this function is causing memory leak.
cv::Mat QImage2Mat(const QImage& src) { cv::Mat mat = cv::Mat(src.height(), src.width(), CV_8UC4, (uchar*)src.bits(), src.bytesPerLine()); cv::Mat result = cv::Mat(mat.rows, mat.cols, CV_8UC3 ); int from_to[] = { 0,0, 1,1, 2,2 }; cv::mixChannels( &mat, 1, &result, 1, from_to, 3 ); return result; }cv::Mat matImage = QImage2Mat(image); -
Hi,
What makes you think there's a memory leak ?