OpenCV: IplImage versus Mat, which to use?

Viewed 29991

I'm pretty new to OpenCV (about 2 months now). I have the book Learning OpenCV by Bradski and Kaehler. My question is, if I want to do everything in a 2.0+ manner, when should I use Matrices (Mat) and when should I use IplImage?

Bradky's book states upfront (Preface) that it's written based on OpenCV 2.0, and it mostly uses IplImage in its sample code, but the more recent online documentation makes it sound like Mat is now a catch-all data type for images, masks, etc, kind of like a basic matrix in Matlab. This leaves me wondering if IplImage should be considered obsolete.

So, should I be totally avoiding IplImages when writing new code? Or is there important stuff IplImages allow me to do that Mats do not?

Thanks.

11 Answers

Quick update:

With the advent of OpenCV 4, the answer to the question will be more straightforward as the IplImage and all of what they now call "the legacy C API" will be progressively removed. In OpenCV 4.0 "alpha", IplImage is already gone - as is CvMat.

So, if you work with OpenCV4.0+, use the Mat Class... because you don't have the choice.

[NB: Of course, if you still use older version of OpenCV, the question is still relevant.]

Related