AttributeError: module 'cv2.cv2' has no attribute 'bgsegm

前端 未结 5 1304
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-19 20:54
import numpy as np
import cv2
cap = cv2.VideoCapture(\'vtest.avi\')
fgbg = cv2.bgsegm.createBackgroundSubtractorMOG()
while(1):
    ret, frame = cap.read()
    fgmask =          


        
5条回答
  •  轮回少年
    2021-02-19 21:05

    Installing contrib dependencies will fix your problem:

    pip install opencv-contrib-python
    

    Alternatively, you can use the newer createBackgroundSubtractorMOG2(), which is directly available in cv2:

    fgbg = cv2.createBackgroundSubtractorMOG2()
    

提交回复
热议问题