QLabel显示opencv Mat图片
QLabel显示opencv Mat图片
void showImgOnLabel(QLabel* labelParam, cv::Mat imgParam, int showType) { cv::Mat rgb; QImage img; if (showType==1) { cv::resize(imgParam, imgParam, cv::Size(640, 480)); } else if (showType==2) { cv::resize(imgParam, imgParam, cv::Size(160, 120)); } if (imgParam.channels() == 3) { cv::cvtColor(imgParam, rgb, CV_BGR2RGB); img = QImage((const uchar*)(rgb.data), rgb.cols, rgb.rows, rgb.cols*rgb.channels(), QImage::Format_RGB888); } else { img = QImage((const uchar*)(imgParam.data), imgParam.cols, imgParam.rows, imgParam.cols*imgParam.channels(), QImage::Format_Indexed8); } labelParam->clear(); labelParam->setPixmap(QPixmap::fromImage(img)); //this->main_ui.labelWin1->resize(this->main_ui.labelWin1->pixmap()->size()); //labelParam->resize(QSize(640, 480)); labelParam->show(); }
#################################
QQ 3087438119