cv2---imread---error

when I use the cv2.imred() which is absolute path  path = r'C:\\Users\\hp\\Desktop\\常用Python代码\\mycv2\\998dcd7a46333361fff21eafd563b3d1.jpg',

it occurred  :    cv2.error: OpenCV(3.4.4) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:356: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'

but use the relative it's ok

 

this is my code:

#coding: utf-8
import cv2
import numpy as np


path = r'C:\\Users\\hp\\Desktop\\常用Python代码\\mycv2\\998dcd7a46333361fff21eafd563b3d1.jpg'
img = cv2.imread(path)

cv2.imshow("image", img)
cv2.waitKey(10000)
cv2.destroyAllWindows()

 

how to solve this problem?

reason:my absolute path has Chinese character 

and I change it, it works

 

#coding: utf-8
import cv2
import numpy as np


path = r'C:\\Users\\hp\\Desktop\\My_Python_Code\\mycv2\\998dcd7a46333361fff21eafd563b3d1.jpg'
img = cv2.imread(path)

cv2.imshow("image", img)
cv2.waitKey(10000)
cv2.destroyAllWindows()

 

posted @ 2019-07-01 17:23  wangaolin  阅读(494)  评论(0编辑  收藏  举报