This is the error I get:
error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\imgproc\src\resize.cpp:3718: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
Already checked for corrupted files.
cat
is an array of 1000 images (RGB).
I am trying to compress these images to (50,50) grayscale.
def greyscale_compress(img):
new_img = cv2.resize(img, (50,50))
img_gray = cv2.cvtColor(new_img, cv2.COLOR_BGR2GRAY)
return img_gray
cat_bin = []
for i in range(0, 100):
cat_bin.append(greyscale_compress(cat[i]))
Generally this problem occurs due to resizing of the image, I just apply try and catch statement for resizing the image so that any error handling. It is working fine and not getting error related to shape.
img=cv2.imread(filename)
print(img)
try:
img = cv2.resize(img, (1400, 1000), interpolation=cv2.INTER_AREA)
print(img.shape)
except:
break
height, width , layers = img.shape
size=(width,height)
print(size)
I had the same issue when I was importing images into a list through label containing the name and path of images.
My problem arose due to an empty space in the list of labels.
I fixed this problem by just removing the space from my label list:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With