using namespace cv;
QImage MatToQImage(const Mat& InputMat)
{
Mat MatImage;
QImage QResult;
if (InputMat.channels() == 1)
{
cv::cvtColor(InputMat, MatImage, CV_GRAY2RGB);
QResult = QImage((const uchar*)(MatImage.data), MatImage.cols, MatImage.rows, MatImage.cols*MatImage.channels(),
QImage::Format_Indexed8);
}
else
{
cv::cvtColor(InputMat, MatImage, CV_BGR2RGB);
QResult = QImage((const uchar*)(MatImage.data), MatImage.cols, MatImage.rows, MatImage.cols*MatImage.channels(),
QImage::Format_RGB888);
}
QResult.bits();
return QResult;
}