Python 使用cv2模块 进入视觉识别的报错,报错信息为AttributeError: module ‘cv2.cv2‘ has no attribute ‘bgsegm

Python 使用cv2模块 进入视觉识别的报错,报错信息为AttributeError: module ‘cv2.cv2’ has no attribute 'bgsegm

Python 使用cv2模块 进入视觉识别的报错,报错信息为AttributeError: module ‘cv2.cv2‘ has no attribute ‘bgsegm_第1张图片

问题描述——cv2模块 进入视觉识别的报错,报错信息为AttributeError: module ‘cv2.cv2’ has no attribute 'bgsegm

Python 使用cv2模块 进入视觉识别的报错,报错信息为AttributeError: module ‘cv2.cv2‘ has no attribute ‘bgsegm_第2张图片

问题原因

网上看了不少文章发现是少了这个模块导致的

后面使用命令安装模块就可以解决,

pip install opencv-contrib-python

但是我这边早就安装了这个模块,还是报错

image.png

后面发现opencv安装顺序可以不对,导致识别不到这个模块

解决方法

使用下面命令重新安装

pip uninstall opencv-python
pip uninstall opencv-contrib-python
pip install opencv-contrib-python

Python 使用cv2模块 进入视觉识别的报错,报错信息为AttributeError: module ‘cv2.cv2‘ has no attribute ‘bgsegm_第3张图片

测试代码如图

Python 使用cv2模块 进入视觉识别的报错,报错信息为AttributeError: module ‘cv2.cv2‘ has no attribute ‘bgsegm_第4张图片

问题解决,

你可能感兴趣的:(数据挖掘,python)