import numpy as np
import cv2
cap = cv2.VideoCapture('vtest.avi')
fgbg = cv2.bgsegm.createBackgroundSubtractorMOG()
while(1):
ret, frame = cap.read()
fgmask = fgbg.apply(frame)
cv2.imshow('frame',fgmask)
k = cv2.waitKey(30) & 0xff
if k == 27:
break
cap.release()
cv2.destroyAllWindows()
I am getting the following error: AttributeError: module 'cv2.cv2' has no attribute 'bgsegm'.
I am using Python 3.6 with OpenCV 3.6 on windows machine. I tried using the pip install opencv-contrib-python command but still the problem remains same on my windows machine. This command helped be on Ubuntu system, but not on windows. I searched similar problems on stack but couldn't solve this issue. Can someone help me out on this? Thanks!
cv2 has no attribute face' in Python - Quora.
No warning as the package also naturally provides cv2 module. opencv-python-headless is unofficial built of opencv-python minus GUI modules that are not required in many cases. Same is expected to be needed for opencv-python-contrib and opencv-python-contrib-headless packages.
You need to install the contrib
dependencies to get this working as it isn't part of the standard build.
pip install opencv-contrib-python
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With