#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->pushButton_2->setEnabled(false); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { QString filename= QFileDialog::getOpenFileName(this,tr("Open Image"), "." , tr("Image Files(*.png *.jpg *.bmp")); image =cv::imread(filename.toAscii().data()); if(image.data) { ui->pushButton_2->setEnabled(true); } cv::imshow("IMG",image); //Mat img; } void MainWindow::on_pushButton_2_clicked() { cv::Mat flipImg; cv::flip(image,flipImg,1); cv::cvtColor(flipImg,flipImg,CV_BGR2RGB); QImage qimg=QImage((unsigned char *)flipImg.data,flipImg.cols,flipImg.rows,QImage::Format_RGB888); ui->label->setPixmap(QPixmap::fromImage(qimg)); ui->label->resize(ui->label->pixmap()->size()); }
[原]opencv学习之QT,Mat 2 QImage
最新推荐文章于 2022-09-02 09:06:08 发布