def __init__(self, video_path, out_path, video_shape, filters, write_capture_info, subtractor='MOG'):
"""Initializer.
Args:
video_path (str): path to video file.
out_path (str): output video destination path.
video_shape (tuple): default size for frame redimensioning.
filters (list): list of filter's names to apply in video source.
write_info (bool): should write frame info when displaying.
subtractor (str): name of background subtractor.
Returns:
None.
"""
if video_path == '-1':
video_path = int(video_path)
self.source = cv2.VideoCapture(video_path)
if not self.source.isOpened():
print('Could not find video file.')
sys.exit()
if subtractor == 'MOG':
self.subtractor = cv2.createBackgroundSubtractorMOG2()
elif subtractor == 'GMG':
self.subtractor = cv2.bgsegm.createBackgroundSubtractorGMG()
self.current_frame = None
self.playing = False
self.video_shape = video_shape
self.codec = cv2.VideoWriter_fourcc(*'XVID')
self.out = cv2.VideoWriter('{}tracking-out.avi'.format(out_path),
self.codec, 30.0, self.video_shape)
self.filters = filters
self.write_capture_info = write_capture_info
self.start()
评论列表
文章目录