What is the best practice to use ? IplImage , CvMat or Mat?

image-processing, opencv

Solution

The types `IplImage` (C) and `CvMat` (C++) correspond to older versions of OpenCV. They are still here for legacy reasons, especially `IplImage` for which there are many code samples on the web.

If you start a fresh project, you should embrass `cv::Mat` and the new C++ API that brings a lot of good (kinf of garbage collection, automatic image alloc/dealloc, data sharing between images, machine learning algorithms...). This API is also actively maintained, while the others may disappear at some point. Algorothms that were implemented in C are also being ported to the recent C++ API.

If you have to reuse older code however, you can learn the basics of `IplImage`, and use constructors of `cv::Mat` that work with `IplImage` as input.

Problem

Which is the best practice to use ? IplImage , CvMat or Mat ? Is CvMat and Mat are same ?

Original source