Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There is several stanges/issues/bugs in your code:

  1. Why when you create QImage you pass 4-th argument as Mat.step()? To create QImage you should provide the number of bytes per line. So the calls should be:

    QImage qoriginal((const uchar*)original.data,original.cols,original.rows,original.cols*3,QImage::Format_RGB888);
    QImage qgray((const uchar*)gray.data,gray.cols,gray.rows,gray.cols,QImage::Format_Grayscale8);
    
  2. Qimage could be created from the raw data only if raw data is continuous, so you need to check:

     if(original.isContinuous() && gray.isContinuous()) {
         // create QImages
     }
    
  3. Update your opencv version to the last one

  4. Use QPainter to draw QImage on the QWidget instead of QLabel with QPixmap, research of how to here