Mat. For this purpose, there are special constructors taking pointers to CvMat or IplImage and the optional flag
indicating whether to copy the data or not.
Backward conversion from Mat to CvMator IplImageis provided via cast operators Mat::operator
CvMat() const and Mat::operator IplImage(). The operators do NOT copy the data.
IplImage*img = cvLoadImage("greatwave.jpg", 1);
Mat mtx(img); // convert IplImage*-> Mat
CvMat oldmat = mtx; // convert Mat -> CvMat
CV_Assert(oldmat.cols == img->width && oldmat.rows == img->height &&
oldmat.data.ptr == (uchar*)img->imageData && oldmat.step == img->widthStep);