0

I want to be able to display an image in a Graphics view using opencv and QT creator. This way that I am posting does work but not exactly what I am looking for. Instead of reading in a already saved image, I want to skip and just pass save_img into the graphics view. Unfortunately doing this causes the image to look distorted and not correct. How could I get around this?

Mat save_img; video >> save_img;

    // Save the frame into a file
imwrite("test.bmp", save_img);

Mat test_read = imread("test.bmp"); 

QGraphicsScene* scene1 = new QGraphicsScene(this);
ui->graphicsView_2->setScene(scene1);
scene1->addPixmap(QPixmap::fromImage(QImage(test_read.data, test_read.cols, test_read.rows, QImage::Format_RGB888)));
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
legit
  • 109
  • 1
  • 2
  • 4
  • why not load file using Qt API? https://doc.qt.io/qt-5/qpixmap.html#QPixmap-2 It seams you do not use any actual functionalities of OpenCV. Also this might be useful: https://stackoverflow.com/a/17137998/1387438 – Marek R Sep 11 '20 at 14:28
  • Does this require the image to saved locally first? – legit Sep 11 '20 at 14:47

0 Answers0