attributeError: 'NoneType' object has no attribute 'shape' 報錯


 

# 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)

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM