解决方案!AttributeError: 'NoneType' object has no attribute 'shape'

报错的原因:调用的对象没有‘shape’属性,也就是没有读取到图片
解决的方法

  • 图片的名字不能为中文,在运行代码相同文件夹下。(这里不用考虑路径里面有没有中文的文件夹名)
path="im.jpg"
img =cv2.imread(path)
  • 不在同一文件夹内,填写图片的绝对路径(路径里面不能有中文)
path="C:/Users/DELL/Desktop/Python/pictures/im.jpg"
img =cv2.imread(path)

猜你喜欢

转载自blog.csdn.net/zhu_rui/article/details/105852846