OPENCV 3.4.*版本 mat转IplIMage报错问题的解决方案

今天遇到了mat 转IplIMage的问题,网上的解决方案都失效了

总结一下失效方案有哪些:

1、  Mat image;

       IplImage src= image;

2、Mat image

 IplImage *src;

*src = IplImage(image);

3、 Mat image;

 

IplImage* src = (IplImage*)&IplImage(image);

4、甚至 mat operator Iplimage()方法都去掉了

5、我只能使用data赋值的方式了

Mat img;

IplImage* ipl_img = cvCreateImage(cvSize(img.cols, img.rows), IPL_DEPTH_8U, img.channels());
memcpy(ipl_img->imageData, img.data, ipl_img->height * ipl_img->widthStep);

不嫌麻烦就遍历赋值,也一样。
        int height = img.rows;
        int width = img.cols;
        int step = ipl_img->widthStep / sizeof(uchar);
        uchar* p_mat = img.data;
        uchar* p_ipl = (uchar*)(ipl_img->imageData);
        for (int i=0;i         {                    
            for (int j=0;j             {                
                p_ipl[i*step+j] = p_mat[i*step+j];                                
            }
        }

 

你可能感兴趣的:(OPENCV 3.4.*版本 mat转IplIMage报错问题的解决方案)