import numpy as np
import cv2
cap = cv2.VideoCapture(\'vtest.avi\')
fgbg = cv2.bgsegm.createBackgroundSubtractorMOG()
while(1):
ret, frame = cap.read()
fgmask =
Most probably this issue arises when someone tries to install multiple packages of OpenCV or even tries to install multiple packages of OpenCV in a different order.
If you read the official opencv-contrib-python
installation docs there is written that you only need to install one package of OpenCV.
For example, if you need a base OpenCV module with extra contrib modules, you just need to install opencv-contrib-python
with the appropriate version you want:
$ pip install opencv-contrib-python
And this will install both OpenCV and OpenCV contrib modules.
The reason for that is all the OpenCV modules use the same namespace which is cv2
and do not use the plugin architecture. So, when you install the other module, it will rewrite the existing namespace with a new module library that is being installed.