Reputation: 285
I am trying to use background Substractor module in opencv. I am referring this blog. I am not able to use it because I again and again get the error message 'module' object has no attribute 'createBackgroundSubtractorMOG'
, I have go-ogled through all the answers to this problem and I have tried using all the substrings possible like - createBackgroundSubtractor
, BackgroundSubtractor
, createBackgroundSubtractorMOG2
etc. but I again get the same error message. I am using -
opencv 3.0.0
python 2.7.10
ubuntu 15.10
here's my code--
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
fgbg = cv2.createBackgroundSubtractorMOG(detectShadows=True)
while(1):
ret, frame = cap.read()
fgmask = fgbg.apply(frame)
cv2.imshow('frame', fgmask)
k = cv2.waitKey(0)
if(k == 27):
break
cap.release()
cv2.destroyAllWindows()
Upvotes: 0
Views: 100
Reputation: 285
Got my question solved. What i did , I opened python command line and wrote dir(cv2)
and it listed me all the functions I can call and there I found BackgroundSubtractorMOG
and it worked!
Upvotes: 0