attributeError: 'NoneType' object has no attribute 'shape' 报错


在最初的代码中, 

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

可能是因为没有设置路径,所以返回的类型是None。

改正的方法是,读取图片时把路径也写上

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM