h = imread.shape[0] AttributeError: 'NoneType' object has no attribute 'shape'
时间: 2023-10-04 20:14:16 浏览: 170
无需降级scipy的情况下解决AttributeError: module ‘scipy.misc’ has no attribute ‘imread’,imresize,imsave等问题
根据引用和引用,出现了一个错误提示"AttributeError: 'NoneType' object has no attribute 'shape'"。这个错误通常是由于img对象为空(NoneType)导致的。在引用中的代码中,使用了cv2.imread()函数加载了一张图片,然后通过print(img.shape)输出了图片的形状。所以问题中的代码"h = imread.shape"中有两个问题:首先,应该使用img而不是imread;其次,应该是img.shape而不是imread.shape。正确的写法应该是"h = img.shape"。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [cv2问题:AttributeError: ‘NoneType‘ object has no attribute ‘shape‘及CV2显示、保存图片](https://blog.csdn.net/qq_38230414/article/details/127045473)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [在Linux系统下img.shape报错AttributeError: 'NoneType' object has no attribute 'shape'](https://blog.csdn.net/qq_34317565/article/details/90672928)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文