close

Platform: Windows 10

OpenCV: 4.2.0

Qt Creator: 4.11.0

image

image

 

image

image

image

 

image

image

 

image

 

image

 

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();
}

image

Add a QLabel for image display

image

 

Setup INCLUDEPATH and LIBS

image

INCLUDEPATH += C:\OpenCV\OpenCV4.2.0DNN\include

LIBS+= -LC:\OpenCV\OpenCV4.2.0DNN\lib \
-lopencv_world420

image

 

 

 

 

 

 

References:

1. OpenCV-2.4.6 with QT5.1 GUI project

2. How to display a Mat image in Qt

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 me1237guy 的頭像
    me1237guy

    天天向上

    me1237guy 發表在 痞客邦 留言(0) 人氣()