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

后端 未结 13 2171
醉酒成梦
醉酒成梦 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:16

    Turns out for me this error was actually telling the truth - I was trying to resize a Null image, which was usually the 'last' frame of a video file, so the assertion was valid.

    Now I have an extra step before attempting the resize operation, which is to do the assertion myself:

    def getSizedFrame(width, height):
    """Function to return an image with the size I want"""    
        s, img = self.cam.read()
    
        # Only process valid image frames
        if s:
                img = cv2.resize(img, (width, height), interpolation = cv2.INTER_AREA)
        return s, img
    

    Now I don't see the error.

提交回复
热议问题