OpenCV: IplImage versus Mat, which to use?

后端 未结 11 1162
一整个雨季
一整个雨季 2020-12-13 01:56

I\'m pretty new to OpenCV (about 2 months now). I have the book Learning OpenCV by Bradski and Kaehler. My question is, if I want to do everything in a 2.0+ manner, when sho

11条回答
  •  庸人自扰
    2020-12-13 02:28

    When writing a Blob detection routine I noticed that using

    IplImage* img;
    uchar* image_src = (uchar*)img->imageData;
    image_src[x+y*width] = ...;
    

    Is much faster than using

    Mat image;
    image.at(x,y) = ...;
    

    About 5x faster. Some of this may be because I used a nested X,Y loop for Mat and a single loop for IplImage. But if you have to write any routines that work directly off pixels I would stick with IplImage.

提交回复
热议问题