OpenCV resize fails on large image with “error: (-215) ssize.area() > 0 in function cv::resize”

后端 未结 13 2185
醉酒成梦
醉酒成梦 2021-01-01 10:08

I\'m using OpenCV 3.0.0 and Python 3.4.3 to process a very large RGB image (107162,79553,3). While I\'m trying to resize it using the following code:

import         


        
13条回答
  •  暖寄归人
    2021-01-01 10:37

    So it turns out that the problem comes from one line in modules\imgproc\src\imgwarp.cpp:

    CV_Assert( ssize.area() > 0 );
    

    When the product of rows and columns of the image to be resized is larger than 2^31, ssize.area() results in a negative number. This appears to be a bug in OpenCV and hopefully will be fixed in the future release. A temporary fix is to build OpenCV with this line commented out. While not ideal, it works for me.

    And I just recently found out that the above applies only to image whose width is larger than height. For images with height larger than width, it's the following line that causes error:

    CV_Assert( dsize.area() > 0 );
    

    So this has to be commented out as well.

提交回复
热议问题