video.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:trackingtermites 作者: dmrib 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号