[Solved] OpenCV – IplImage

What is IplImage in OpenCV? Can you just explain what is meant by it as a type? When should we use it?

Thanks.

Solution #1:

Based on the ‘c++’ tag you have in your question:
You should not use it, you should use cv::Mat. Every IplImage is a cv::Mat internally.

IplImage is only used in the C API. It is a kind of CvMat and holds image data. Its name originates from OpenCV’s roots (Intel IPL).

It is not relevant anymore if you use the C++ API of OpenCV.

Respondent: ypnos

Solution #2:

IplImage and cv::Mat are different header types for matrix/image data. They’re basically compatible with each other, but IplImage is used in OpenCV’s C API, while cv::Mat is used in the new C++ API.

When you decide to use OpenCV’s C API, you will mostly use IplImages. Otherwise you will mostly use cv::Mats.

Of course, you can convert IplImages and cv::Mats to each other, e.g.

cv::Mat mat(myIplImage);

In this case, they share the same underlying data, i.e. modifications made through either header will be visible regardless of what header you’re using to access the data.

Deep-copy (not only header is “transformed”/copied, but also the underlying data) is possible with

cv::Mat mat(myIplImage, true)

Note that multiple IplImages can also point to the same underlying data, as can multiple cv::Mats.


When working with OpenCV and similar libraries it is important to notice that cv::Mats and IplImages are only “headers” for the actual data. You could say that cv::Mats and IplImages are basically pointers plus important meta information like number of rows, columns, channels and the datatype used for individual cells/pixels of the matrix/image. And, like real pointers, they can reference/point to the same real data.

For example, look at the definition of IplImage: http://opencv.willowgarage.com/documentation/basic_structures.html#iplimage

The most important member is char *imageData;. This pointer references the actual image data. However, the IplImage as a whole contains meta information about the image as well, like number of rows and columns.

Respondent: robert

Solution #3:

The IplImage structure was inherited from the Intel Image Processing Library, in which the format is native. OpenCV only supports a subset of possible IplImage formats, as outlined in the parameter list above.

Respondent: Soumajyoti

Solution #4:

If you are usin C++ you don´t use IplImage because this only use in a C program, (IplImage is in C API).
In addition if you are usin C you need post Cv before the variables names: “CvMat *” “CvPoint ” “IplImage ” etc.
It ´s better to use C++ code, you don´t use Cv: “Mat *
” etc. but you can´t use the IplImage type, instead of IplImage you use a Mat type for example in findchessboardcorner function.

Respondent: Isra-MiAn

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.