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

孤街醉人 提交于 2019-12-24 23:12:28

问题


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 ?


回答1:


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

Then

cv::Mat img2(iplImg);



回答2:


#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..



来源:https://stackoverflow.com/questions/12355547/how-to-convert-from-c-interface-cvmat-to-c-iplimage

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!