#!/usr/bin/env python
# -*- coding: gbk -*-
import cv2
img_head = cv2.imread('月亮.jpg')
img_flag = cv2.imread('国旗.png')
#获取头像和国旗图案宽度
# ~ w_head, h_head = img_head.shape[0:2]
print(img_head.shape[:
2021-10-04_cv2.imread()_AttributeError: ‘NoneType’ object has no attribute ‘shape’
在尝试读取图片并输出其尺寸时遇到AttributeError:'NoneType' object has no attribute 'shape'。错误原因为cv2.imread()无法正确读取包含中文路径的图片。解决方案是确保图片路径不含中文,并测试了路径格式,如路径分隔符和盘符的使用。修复这个问题后,程序成功运行。

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



