OpenCV 'imshow' Error: Image Width or Height is Zero
The error message indicates that there is an assertion failed in the 'imshow' function of OpenCV. This error occurs when the width or height of the image is equal to or less than zero.
To fix this error, you can check if the image was successfully loaded before displaying it using 'imshow'. Here's an example:
import cv2
img = cv2.imread('1.jpg')
if img is not None:
# Display the image
cv2.imshow('demo', img)
# Wait for a key press
cv2.waitKey(0)
else:
print('Failed to load image')
Make sure that the image file '1.jpg' exists in the correct location.
原文地址: https://www.cveoy.top/t/topic/pdS8 著作权归作者所有。请勿转载和采集!