错误:AttributeError: module ‘cv2.cv2‘ has no attribute ‘TrackerCSRT_create‘ 解决

OpenCV目标跟踪运行出错:AttributeError: module ‘cv2.cv2’ has no attribute 'TrackerCSRT_create’C

问题:

直接上错误代码:
意思就是没有找到‘TrackCSRT_create'
上我的代码:
在这里插入图片描述

寻求解决方案:

我这个是看着B站’啥都会一点的研究生‘B站的UP主的opencv的视频跟着运行他的代码,但是出了这个错误,然后就去上网查解决方案,找到了一个,说是缺少opencv-contrib-python包,但是我记得我装了啊
我立即去cmd查查,结果如下:
在这里插入图片描述
直接在cmd上面输入pip list 查自己所有的包
果然没有opencv_contrib_python
只有opencv_python包
然后就去下载,这里说一下啊,尽量用从清华镜像下载,不然特别慢下面是代码,用pip下载的:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python

这是代码,这个默认是下载最新版本,当然你也可以选择版本,只需要在后面加上版本就行了。


pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python==3.4.1.15
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python==3.4.1.15

这种就是加了版本,不加的话是默认最新版本的。
下面是速度,很快,不到一分钟就下载好了。

错误:AttributeError: module ‘cv2.cv2‘ has no attribute ‘TrackerCSRT_create‘ 解决_第1张图片
然后去pip list 查一下,怎么样。
在这里插入图片描述
两个都有了。

再次出现问题及解决方法:

自己去运行了代码,发现还是出错,然后细心想下,我用的pycharm,为了保险起见,我在pycharm上面也装上了python_contrib_python的包

错误:AttributeError: module ‘cv2.cv2‘ has no attribute ‘TrackerCSRT_create‘ 解决_第2张图片

点***Settings,***进去设置
错误:AttributeError: module ‘cv2.cv2‘ has no attribute ‘TrackerCSRT_create‘ 解决_第3张图片

错误:AttributeError: module ‘cv2.cv2‘ has no attribute ‘TrackerCSRT_create‘ 解决_第4张图片
添加包

错误:AttributeError: module ‘cv2.cv2‘ has no attribute ‘TrackerCSRT_create‘ 解决_第5张图片
搜索包,然后
错误:AttributeError: module ‘cv2.cv2‘ has no attribute ‘TrackerCSRT_create‘ 解决_第6张图片
然后安装包
错误:AttributeError: module ‘cv2.cv2‘ has no attribute ‘TrackerCSRT_create‘ 解决_第7张图片
出现这个就是安装成功了,去运行程序
错误:AttributeError: module ‘cv2.cv2‘ has no attribute ‘TrackerCSRT_create‘ 解决_第8张图片
可以了,运行成功!!

你可能感兴趣的:(错误:AttributeError: module ‘cv2.cv2‘ has no attribute ‘TrackerCSRT_create‘ 解决)