C++ OpenCV - IplImage

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5192578/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 17:38:25  来源:igfitidea点击:

OpenCV - IplImage

c++opencviplimage

提问by Simplicity

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

什么IplImageOpenCV?你能解释一下它作为一种类型的含义吗?我们应该什么时候使用它?

Thanks.

谢谢。

回答by ypnos

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.

基于你在问题中的“c++”标签: 你不应该使用它,你应该使用 cv::Mat。每个 IplImage 内部都是一个 cv::Mat。

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).

IplImage 仅用于 C API。它是一种 CvMat 并保存图像数据。它的名字源于 OpenCV 的根源(Intel IPL)。

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

如果您使用 OpenCV 的 C++ API,则不再相关。

回答by robert

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 newC++ API.

IplImage 和 cv::Mat 是矩阵/图像数据的不同标题类型。它们基本上是相互兼容的,但是在 OpenCV 的 C API 中使用了 IplImage,而在新的C++ API 中使用了 cv::Mat 。

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

当您决定使用 OpenCV 的 C API 时,您将主要使用 IplImages。否则,您将主要使用 cv::Mats。

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

当然,您可以将 IplImages 和 cv::Mats 相互转换,例如

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.

请注意,多个 IplImage 也可以指向相同的底层数据,多个 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 informationlike 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 realdata.

在使用 OpenCV 和类似库时,重要的是要注意 cv::Mats 和 IplImages 只是实际数据的“标题”。你可以说 cv::Mats 和 IplImages 基本上是指针加上重要的元信息,如行数、列数、通道数和用于矩阵/图像的单个单元格/像素的数据类型。而且,就像真正的指针一样,它们可以引用/指向相同的真实数据。

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;. This pointer references the actualimage data. However, the IplImage as a wholecontains meta information about the image as well, like number of rows and columns.

最重要的成员是char *imageData;. 此指针引用实际图像数据。但是,整个 IplImage包含有关图像的元信息,例如行数和列数。

回答by Soumajyoti

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.

IplImage 结构继承自英特尔图像处理库,其格式为原生格式。OpenCV 仅支持可能的 IplImage 格式的子集,如上面的参数列表中所述。

回答by Isra-MiAn

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.

如果您使用 C++,则不要使用 IplImage,因为它仅在 C 程序中使用,(IplImage 在 C API 中)。此外,如果您使用 C,则需要在变量名称之前发布 Cv:"CvMat *" "CvPoint” “图像 " 等。最好使用 C++ 代码,您不要使用 Cv: "Mat *" 等,但您不能使用 IplImage 类型,而是使用 IplImage 类型,例如在 findchessboardcorner 函数中使用 Mat 类型。