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’ error

The returned type may be none because the path is not set

The correct way is to write the path when reading the picture

import cv2

img = cv2.imread(r"D:\PythonCode\neuron\image0.jpg", 1)
imgInfo = img.shape
print(imgInfo)

  

Similar Posts: