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

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

 

1
2
3
4
5
6
7
8
9
10
// 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 @   gaoxw0511  阅读(593)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示