简体   繁体   中英

How to convert from c++ interface cv::Mat to c IplImage?

How to convert from c++ interface cv::Mat to c IplImage ? such that i used
IplImage * lpl= matimage;

and matimage contain data and after some operation i want to do inverse convert. from IplImage* lpl ===> cv::Mat can i use a copy data and how ?

cv::Mat img = ....;
IplImage iplImg = img;

Then

cv::Mat img2(iplImg);
#include "iostream"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

int main()
{
    Mat image = imread("C:\\lena.jpg");
    IplImage image2 = image;
    cvShowImage("TESTiplimage",&image2);
    imshow("TESTmat",image);
    waitKey(0);

    return 0;
}

...try this code it...it works for me...you should get 2 windows showing the same image..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM