attributeError: ‘NoneType’ object has no attribute ‘shape’

How did “people you might know” find you on social software>>>

In the original code

#read an image
    img = cv2.imread('image.jpg')
    
    #print the dimension of the image
    print img.shape

It may be that the path is not set, so the returned type is none

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

#Try changing the direction of the slashes

im = cv2.imread("D:/testdata/some.tif",CV_LOAD_IMAGE_COLOR)

#or add r to the begining of the string

im = cv2.imread(r"D:\testdata\some.tif",CV_LOAD_IMAGE_COLOR)

Similar Posts: