一、帧差法
二、实现
import cv2
# 视频文件输入初始化
filename = "move_detect.flv"
camera = cv2.VideoCapture(filename) #打开视频/摄像头
# 视频文件输出参数设置
out_fps = 12.0 # 输出文件的帧率
fourcc = cv2.VideoWriter_fourcc('M', 'P', '4', '2') #指定保存视频的编码格式
out1 = cv2.VideoWriter('v1.avi', fourcc, out_fps, (500, 400))
out2 = cv2.VideoWriter('v2.avi', fourcc, out_fps, (500, 400))
# 初始化当前帧的前帧
lastFrame = None
# 遍历视频的每一帧
while camera.isOpened():
ret, frame = camera.read()
if not ret: