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
posted @ 2012-03-15 13:52  gaoxw0511  阅读(591)  评论(0编辑  收藏  举报