Ask Your Question

Revision history [back]

help regarding MOG back ground subtraction using opencv

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'

click to hide/show revision 2
retagged

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

berak gravatar image

help regarding MOG back ground subtraction using opencv

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'