Qlabel显示图像扭曲,解决方法:
https://blog.csdn.net/loveaborn/article/details/7680834
void test::processButton()
{
cv::Mat rgbImage;
cv::Mat grayImage;
QImage dstImage;
if (!image.empty())
{
if (image.channels() == 3) // RGB image
{
cvtColor(image, rgbImage, CV_BGR2RGB);
dstImage = QImage((const uchar*)(rgbImage.data), //(const unsigned char*)
rgbImage.cols, rgbImage.rows,
rgbImage.cols*rgbImage.channels(), //new add
QImage::Format_RGB888);
}
else // gray image
{
dstImage = QImage((const uchar*)(image.data),
image.cols, image.rows,
image.cols*image.channels(), //new add
QImage::Format_Indexed8);
}
//dstImage = dstImage.scaled(ui.imageLabel->size());//原图自适应label
ui.imageLabel->setPixmap(QPixmap::fromImage(dstImage));
ui.imageLabel->resize(ui.imageLabel->pixmap()->size()); //label自适应cv::Mat大小
ui.imageLabel->show();
}
}