OpenCV - IplImage

廉价感情. 提交于 2019-11-27 13:02:49

问题


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

Thanks.


回答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.




回答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.




回答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.




回答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.



来源:https://stackoverflow.com/questions/5192578/opencv-iplimage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!