Ask Your Question
0

help regarding MOG back ground subtraction using opencv

asked 2017-07-10 06:18:14 -0600

updated 2017-07-10 06:46:29 -0600

berak gravatar image

hi, i have been working ono mog background subtraction with the following program,if i use mog2 it is working but working on mog and gmg doesnt seem to work,i am using opencv3.2.0

the program is

import numpy as np import cv2

cap = cv2.VideoCapture(0)

fgbg = cv2.BackgroundSubtractorMOG()

while(1): ret, frame = cap.read()

fgmask = fgbg.apply(frame)

cv2.imshow('frame',fgmask) if cv2.waitKey(1) & 0xFF == ord('q'): break

cap.release() cv2.destroyAllWindows()

this is the error coming

File "back.py", line 6, in <module> fgbg = cv2.BackgroundSubtractorMOG2() AttributeError: 'module' object has no attribute 'BackgroundSubtractorMOG2'

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-07-10 06:46:02 -0600

berak gravatar image

updated 2017-07-11 23:58:15 -0600

MOG and GMG were moved to opencv_contrib with opencv3, and you have to call a "create" function, not a constructor, like:

 fgbg = cv2.createBackgroundSubtractorMOG2()

also have a look at:

 >>> help(cv2.createBackgroundSubtractorMOG2())
edit flag offensive delete link more

Comments

hey i tried the mog2 subtractor is working,but MOG and GMG are not working,i have also installed opencv_contirb,but i still get errors

arvvind gravatar imagearvvind ( 2017-07-10 23:33:11 -0600 )edit

cv2.bgsegm.createBackgroundSubtractorMOG()

berak gravatar imageberak ( 2017-07-11 00:47:38 -0600 )edit
1

sir, i tried this to,yet couldnt get the result,,,can you kindly mention me opencv version and link to install opencv and opencv contrib again

arvvind gravatar imagearvvind ( 2017-07-11 23:50:18 -0600 )edit

apologies, i got it all wrong, initially, it's createXXXX(), not XXXX_create()

berak gravatar imageberak ( 2017-07-11 23:59:24 -0600 )edit

berak ,i tried either mais there any way to check whether the extra modules has been installed,when i ran installation it showed sucees oly..,

arvvind gravatar imagearvvind ( 2017-07-13 00:06:58 -0600 )edit

^^ sorry i have no idea, what you are talking about.

berak gravatar imageberak ( 2017-07-13 02:40:08 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2017-07-10 06:18:14 -0600

Seen: 296 times

Last updated: Jul 11 '17