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)
);
INCLUDEPATH += /usr/local/include/opencv4/
LIBS+= -L/usr/local/lib/ \
`pkg-config --cflags --libs opencv4`
全站熱搜
留言列表