cv2.error: OpenCV(3.4.3) C:projectsopencv-python opencv modules high guisrc window.cpp:356...

created at 07-06-2021 views: 4


error message:

cv2.error: OpenCV(3.4.3) C:projectsopencv-pythonopencvmoduleshighguisrcwindow.cpp:356: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'

error code:

import cv2 as cv
from matplotlib import pyplot as plt

# Draw a histogram
def hist_image(image):
    color = ('blue', 'green', 'red')
    for i, color in enumerate(color):
        hist = cv.calcHist([image], [i], None, [256], [0, 256])
        plt.plot(hist, color=color)
        plt.xlim([0, 256])

src = cv.imread(r'D:\pic\图片.jpg')
cv.namedWindow('y', cv.WINDOW_NORMAL)
cv.imshow('y', src)


The reason is that the picture is not read correctly

Please test if the image is loaded correctly first

In the wrong attitude, change the name of the photo file to English and it will be OK!

Please log in to leave a comment.