close
Platform: Windows 10
OpenCV: 4.2.0
Qt Creator: 4.11.0
void MainWindow::on_pushButton_clicked()
{
Mat img = imread("C:/OpenCV/images/lena.jpg");
cvtColor(img, img, COLOR_BGR2RGB);
ui->label->setPixmap(
QPixmap::fromImage(
QImage(img.data, img.cols, img.rows, img.step, QImage::Format_RGB888)
)
);
waitKey();
}
Add a QLabel for image display
Setup INCLUDEPATH and LIBS
INCLUDEPATH += C:\OpenCV\OpenCV4.2.0DNN\include
LIBS+= -LC:\OpenCV\OpenCV4.2.0DNN\lib \
-lopencv_world420
References:
1. OpenCV-2.4.6 with QT5.1 GUI project
2. How to display a Mat image in Qt
全站熱搜
留言列表