Ask Your Question
1

cant find 'BackgroundSubtractorMOG2' opencv3.1.0 [closed]

asked 2016-11-19 19:22:30 -0600

aliyesami gravatar image

updated 2016-11-19 19:23:24 -0600

sorry after closing the previous thread I tested and I can't find the "'BackgroundSubtractorMOG2'" module ? I have the MOG and GMG in the sv2.bgsegm though.

[root@hadoop1 scripts]# python
Python 3.3.3 (default, Nov 16 2016, 14:57:45)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> fpbg=cv2.BackgroundSubtractorMOG2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'BackgroundSubtractorMOG2'
>>> import cv2.bgsegm
>>> fpbg=cv2.BackgroundSubtractorMOG2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'BackgroundSubtractorMOG2'
>>>
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by aliyesami
close date 2016-11-19 19:30:28.269500

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-11-19 19:26:40 -0600

berak gravatar image

updated 2016-11-19 19:33:57 -0600

api has changed between 2.4 and 3.1. use:

fpbg=cv2.createBackgroundSubtractorMOG2()
fpbg=cv2.createBackgroundSubtractorKNN()

and the MOG and GMG versions are in the bgsegm module in opencv_contrib, so that's:

fpbg=cv2.bgsegm.createBackgroundSubtractorMOG()
fpbg=cv2.bgsegm.createBackgroundSubtractorGMG()
edit flag offensive delete link more

Comments

1

thanks for your help

aliyesami gravatar imagealiyesami ( 2016-11-19 19:30:18 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-11-19 19:22:30 -0600

Seen: 5,539 times

Last updated: Nov 19 '16