We may often face such confusion, Iplimage and mat, which data structures we should use.
Iplimage was in the OpenCV library from the beginning, and he came from Intel's other library, the Intel Image Processing Library (IPL), which is a very important data structure. In the classic book of the sample used basically is iplimage this data structure. But this is a C-style data structure, and you have to allocate and free memory for him.
Mat is a new data structure, and more and more people are using it because it is object-oriented. So we don't need to manage the memory for it ourselves. It is referenced by counting, and if it has a reference count of 0, it will automatically free up memory.
Honestly, I don't know what data structure to use. Because I think there are some methods, mat data structure is not available, and some methods can only use Iplimage.
Convert Iplimage to Mat
IplImage* ipl;Mat m = cvarrToMat(ipl);
Iplimage versus Mat