# 1 load 2 info 3 resize 4 check
import cv2
img = cv2.imread("image0.jpg", 1)
imgInfo = img.shape
print(imgInfo)
attributeError: 'NoneType' object has no attribute 'shape' 報錯
可能是因為沒有設置路徑,所以返回的類型是None。
改正的方法是,讀取圖片時把路徑也寫上
import cv2 img = cv2.imread(r"D:\PythonCode\neuron\image0.jpg", 1) imgInfo = img.shape print(imgInfo)
