close

Unfortunately Qt creator in linux does not support BGR888 format, so we have to convert the image to RGB format by using cvtColor funtion before displaying it.


Mat img = imread("lena.jpg");
cvtColor(img, img, COLOR_BGR2RGB);
auto w = ui->label->width();
auto h = ui->label->height();
ui->label->setPixmap(
   QPixmap::fromImage(
   QImage(img.data, img.cols, img.rows, img.step, QImage::Format_RGB888)
   ).scaled(w, h, Qt::KeepAspectRatio)

);

image


INCLUDEPATH += /usr/local/include/opencv4/
LIBS+= -L/usr/local/lib/ \
`pkg-config --cflags --libs opencv4`
image
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 me1237guy 的頭像
    me1237guy

    天天向上

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