首页 > 解决方案 > Python 找不到来自 cv2 的 bgsegm

问题描述

我正在尝试测试一些背景减法方法(按照教程),但 Python 无法找到它们。

使用 Windows 和 Anaconda。我确保通过 conda升级opencv并运行

点安装 opencv-contrib-python

另一个相关问题中建议的命令。

不过,我明白了:

(tracx) C:\Users\USER>python
Python 3.5.4 |Anaconda, Inc.| (default, Nov  8 2017, 14:34:30) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> fgbg = cv2.createBackgroundSubtractorMOG()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'cv2.cv2' has no attribute 'createBackgroundSubtractorMOG'
>>> quit()

标签: pythonopencvcondabackground-subtraction

解决方案


你一定在寻找f = cv2.bgsegm.createBackgroundSubtractorMOG()

该功能当前位于bgseg(背景分割)模块中。


推荐阅读