Assertion failure : size.width>0 && size.height>0 in function imshow

前端 未结 10 1287
失恋的感觉
失恋的感觉 2020-11-30 12:19

i am using opencv2 and python on raspberry pi. and i am new with python and opencv. i tried to read a jpeg image and display image it shows the following error:

<         


        
10条回答
  •  误落风尘
    2020-11-30 13:05

    Use r in the code where you specified the file address.
    For Example:

    import cv2
    img = cv2.imread(r'D:\Study\Git\OpenCV\resources\lena.png')
    cv2.imshow('output', img)
    cv2.waitKey(0)
    

    r stands for "raw" and will cause backslashes in the string to be interpreted as actual backslashes rather than special characters.

提交回复
热议问题