cv::Mat to QImage and back

前端 未结 2 993
自闭症患者
自闭症患者 2020-11-27 18:27

//Sorry for my english.

Tell me please, what I am doing wrong? I have read a lot about this. And write some code, but I have a terrible result.

As I

2条回答
  •  长情又很酷
    2020-11-27 18:28

    Thanks a Lot! It is realy works! But. Why does memory whas spoiled? First. I have some memory load incv::Mat

    cv::Mat mat1 = cv::imread("bugero.jpg",3);
    
    mat1 - [=====================================]
    

    then I put a copy of this cvMat to other cv:Mat

    cv::Mat temp(src.cols,src.rows,src.type());
    cvtColor(src, temp,CV_BGR2RGB);
    
    mat1  -  [=========================================]
    
    temp  -  [=========================================]
    

    then make QImage from this data QImage dest= QImage((uchar*) temp.data, temp.cols, temp.rows, temp.step, QImage::Format_RGB888);

    mat1  -   [============================================]
    
    temp  - > [============================================]
             /
    dest --/
    

    And then temp goes out of scope and delete it self? QImage does not take ownership of it so memory in temp1 and dest marked as free, and there compiler can put other data? Is I am right?

提交回复
热议问题