简体   繁体   English

OpenCV - IplImage

[英]OpenCV - IplImage

What is IplImage in OpenCV ? 什么是OpenCV IplImage Can you just explain what is meant by it as a type? 你能解释一下它的含义吗? When should we use it? 我们什么时候应该使用它?

Thanks. 谢谢。

Based on the 'c++' tag you have in your question: You should not use it, you should use cv::Mat. 基于您在问题中的'c ++'标签: 您不应该使用它,您应该使用cv :: Mat。 Every IplImage is a cv::Mat internally. 每个IplImage都是内部的cv :: Mat。

IplImage is only used in the C API. IplImage仅用于C API。 It is a kind of CvMat and holds image data. 它是一种CvMat并保存图像数据。 Its name originates from OpenCV's roots (Intel IPL). 它的名字源自OpenCV的根源(Intel IPL)。

It is not relevant anymore if you use the C++ API of OpenCV. 如果您使用OpenCV的C ++ API,则不再相关。

IplImage and cv::Mat are different header types for matrix/image data. IplImage和cv :: Mat是矩阵/图像数据的不同头类型。 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. 它们基本上是相互兼容的,但IplImage用于OpenCV的C API,而cv :: Mat用于新的 C ++ API。

When you decide to use OpenCV's C API, you will mostly use IplImages. 当您决定使用OpenCV的C API时,您将主要使用IplImages。 Otherwise you will mostly use cv::Mats. 否则你将主要使用cv :: Mats。

Of course, you can convert IplImages and cv::Mats to each other, eg 当然,您可以将IplImages和cv :: Mats互相转换,例如

cv::Mat mat(myIplImage);

In this case, they share the same underlying data, ie 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. 请注意,多个IplImages也可以指向相同的基础数据,多个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. 使用OpenCV和类似的库时,重要的是要注意cv :: Mats和IplImages只是实际数据的“标题”。 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. 您可以说cv :: Mats和IplImages基本上是指针加上重要的元信息,例如行数,列数,通道数和用于矩阵/图像的单个单元/像素的数据类型。 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 例如,看一下IplImage的定义: http ://opencv.willowgarage.com/documentation/basic_structures.html#iplimage

The most important member is char *imageData; 最重要的成员是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. 但是,IplImage 作为一个整体包含有关图像的元信息,例如行数和列数。

The IplImage structure was inherited from the Intel Image Processing Library, in which the format is native. IplImage结构继承自英特尔图像处理库,其格式为原生。 OpenCV only supports a subset of possible IplImage formats, as outlined in the parameter list above. OpenCV仅支持可能的IplImage格式的子集,如上面的参数列表中所述。

If you are usin C++ you don´t use IplImage because this only use in a C program, (IplImage is in C API). 如果您使用C ++,则不要使用IplImage,因为这仅用于C程序,(IplImage在C API中)。 In addition if you are usin C you need post Cv before the variables names: "CvMat *" "CvPoint 另外如果您使用C,则需要在变量名称之前发布Cv:“CvMat *”“CvPoint " "IplImage “”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. “等等。最好使用C ++代码,不要使用Cv:”Mat * “等,但是你不能使用IplImage类型,而不是IplImage,你可以在findchessboardcorner函数中使用Mat类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM