【opencv】背景消除

测试用例:

【opencv】背景消除_第1张图片

import numpy as np
import cv2

cap = cv2.VideoCapture('test.avi')

fgbg = cv2.createBackgroundSubtractorMOG2()

while(1):
    ret, frame = cap.read() 
    fgmask = fgbg.apply(frame) # 对背景进行消除
    cv2.imshow('frame',fgmask) # 显示消除后的背景
    k = cv2.waitKey(30) & 0xff  # 每30ms显示一帧
    if k == 27:
        break

cap.release()
cv2.destroyAllWindows()

 【opencv】背景消除_第2张图片

你可能感兴趣的:(opencv,opencv,人工智能,计算机视觉)