Qimage to cv::Mat convertion strange behaviour

后端 未结 6 2237
离开以前
离开以前 2020-12-19 16:18

I am trying to create an application where I am trying to integrate opencv and qt.

I managed successfully to convert a cv::Mat to QImage by using the code below:

6条回答
  •  渐次进展
    2020-12-19 17:07

    This is what i got from here thanks to jose. It helps me to get over this.

    To visualize OpenCV image (cv::Mat) in Qt (QImage), you must follow these steps:

    1. Invert color sequence: cv::cvtColor(imageBGR, imageRGB, CV_BGR2RGB);
    2. Change format OpenCV to Qt: QImage qImage((uchar*) imageRGB.data, imageRGB.cols, imageRGB.rows, imageRGB.step, QImage::Format_RGB888);
    3. Use QPainter to render the image.

    Please note the use of QImage::Format. Read the Qt on this issue.

提交回复
热议问题