IplImage or CvMat to Mat

IplImage or CvMat to Mat

 

 

> IplImage or CvMat -----> cv::Mat:

   > from definition of cv::Mat

// converts old-style CvMat to the new matrix; the data is not copied by default
Mat(const CvMat* m, bool copyData=false);
// converts old-style IplImage to the new matrix; the data is not copied by default
Mat(const IplImage* img, bool copyData=false);
IplImage *myIplImage = cvCreateImage(...);
Mat myIplImageMat=Mat(myIplImage,true);
//true if you wish an independent copy else it will change myIplImage data

 Vice-Versa:

//again, from the definition of cv::Mat
// converts header to CvMat; no data is copied
operator CvMat() const;
// converts header to IplImage; no data is copied
operator IplImage() const;

 

That is:

Mat myMat=Mat(...);
IplImage myIplImageMat=myMat; //without * !!!
vWhatEverOldCFunction(&myMat,...other arguments); 
// or 
Mat mat ...
IplImage *trans = &IplImage(mat);


 

 

Reference

[1] opencv-users

http://opencv-users.1802565.n2.nabble.com/IplImage-lt-gt-cv-Mat-td5317470.html

 

 

댓글

Designed by JB FACTORY