OpenCV - IplImage
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
根据您问题中的“c++”标签:
你不应该使用它,你应该使用 cv::Mat。 每个 IplImage 内部都是一个 cv::Mat。
IplImage 仅在 C API 中使用。它是一种 CvMat,保存图像数据。它的名字源自 OpenCV 的根源(Intel IPL)。
如果您使用 OpenCV 的 C++ API,则不再相关。
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.
IplImage 和 cv::Mat 是矩阵/图像数据的不同标头类型。它们基本上是相互兼容的,但是 IplImage 用于 OpenCV 的 C API 中,而 cv::Mat 用于 new C++ API 中。
当您决定使用 OpenCV 的 C API 时,您将主要使用 IplImages。否则你将主要使用 cv::Mats。
当然,您可以将 IplImages 和 cv::Mats 相互转换,例如,
在这种情况下,它们共享相同的基础数据,即无论您使用哪个标头来访问数据,通过任一标头进行的修改都将可见。
深度复制(不仅标头被“转换”/复制,而且底层数据也被“转换”/复制)可以使用 注意
,多个 IplImage 也可以指向相同的底层数据,多个 cv::Mats 也可以。
使用 OpenCV 和类似库时,请务必注意 cv::Mats 和 IplImages 只是实际数据的“标头”。 您可以说 cv::Mats 和 IplImages 基本上是指针加上重要的元信息,例如行数、列数、通道数以及用于矩阵/图像的各个单元格/像素的数据类型。 而且,就像真正的指针一样,它们可以引用/指向相同的真实数据。
例如看IplImage的定义: http://opencv.willowgarage.com/documentation/basic_structs.html# iplimage
最重要的成员是
char *imageData;
。该指针引用实际图像数据。然而,IplImage作为一个整体也包含有关图像的元信息,例如行数和列数。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.
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
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.IplImage结构继承自Intel图像处理库,其中格式是原生的。 OpenCV 仅支持可能的 IplImage 格式的子集,如上面的参数列表中所述。
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.
如果您使用 C++,则不会使用 IplImage,因为它仅在 C 程序中使用(IplImage 在 C API 中)。
此外,如果您使用 C,则需要在变量名称之前添加 Cv: "CvMat *" "CvPoint " "IplImage < /em>" 等
最好使用 C++ 代码,不要使用 Cv: "Mat *" 等,但不能使用 IplImage 类型,而是使用 Mat 类型代替 IplImage,例如在 findchessboardcorner 函数中。
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.