Mat 和 IplImage、CvMat格式的互相转换

根据最新的manual ,Mat和CvMat,IplImage的相互转化方法如下:

// Convert an IplImage or CvMat to an cv::Mat and a cv::Mat to an 
// IplImage or CvMat:
// Assuming somewhere IplImage *iplimg; exists
// and has been allocated and cv::Mat Mimg has been defined
Mat imgMat(iplimg); //Construct an Mat image "img" out of an IplImage
Mimg = iplimg; //Or just set the header of pre existing cv::Mat
//Ming to iplimg’s data (no copying is done)
//Convert to IplImage or CvMat, no data copying
IplImage ipl_img = img;
CvMat cvmat = img; // convert cv::Mat -> CvMat
原文地址:https://www.cnblogs.com/xiangwengao/p/2397958.html