环境:
python3.6.4
opencv3.4.1.15
运行目标跟踪object_tracking文件夹中的mean函数时报错且不显示视频结果
Traceback (most recent call last):
File "F:\pycharm_python\projects\project_python_test\object_tracking\main.py", line 15, in <module>
height, width, _ = frame.shape
AttributeError: 'NoneType' object has no attribute 'shape'
查找原因基本上看见三个
1.图片不存在(路径不存在, 路径包含中文无法识别) 2.读取的图片内容和默认读取时参数匹配不匹配。(默认读取的是3通道的彩色图)例如读取到的图片是灰度图,就会返回None。3.也可能是路径中有中文(59条消息) AttributeError: 'NoneType' object has no attribute 'shape'_旅人_Eric的博客-CSDN博客
自己分析了一下,肯因为程序中是相对路径,
cap =cv2.VideoCapture("highway.mp