OpenCV - IplImage

前端 未结 4 2167
借酒劲吻你
借酒劲吻你 2020-12-14 09:42

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

Thanks.

4条回答
  •  盖世英雄少女心
    2020-12-14 10:10

    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.

提交回复
热议问题