According to OpenCV tutorial( http://docs.opencv.org/doc/tutorials/core/mat_the_basic_image_container/mat_the_basic_image_container.html ), you are recommended to use Mat class instead of typical IplImage class.
There are important reasons why you should use Mat class.
1. memory copy issue
Since processing mass data like image requires heavy load due to data copy, minimizing memory copy issue is important.
Mat class basically supports mechanism to minimize memory copy between image processing steps.
For this, Mat class consists of header and data space.
To move to next step of image processing, Mat class just switches headers which have address pointing actual image data.
2. memory management
Memory leak problem is critical In image processing application because size of the leak is mass.
Furthermore, frequent memory allocation and releasing wastes a lot of processor resource and memory management is not easy in multitasking structure.
Thus, smart pointer is a good solution for this issue.
Mat class uses memory reference counter like boost shared pointer which supports automatic releasing unused memory that allows users to access memory space without concerning memory management.
3. good match with c++
Basically, old Iplimage structure is designed for C language.
APIs for Iplimage is c style fuctions such as cvImageload, cvCvtColor.
However, Mat class is designed for object oriented language, C++.
APIs for Mat class is surely object oriented style.
For these reasons, OpenCV tutorial recommends to use Mat class if you are not programming based on C language for embedded system.
No comments:
Post a Comment