def __init__(self, gt_path, video_path, metric_func, init=True, classifier=None): self.classifier = classifier self.capture = create_capture(video_path) self.converter = VideoFrameConverter(self.capture) self.ground_truth = GTHVideoSubstrates(gt_path, self.capture) self.classes = self.ground_truth.classes_present self.metric = metric_func self.training_frames = [] # Stores all frames used in training self.x = [] # frames n_samples * n_features self.y = [] # labels n_samples self.classifier.ground_truth = gt_path self.classifier.video_path = video_path self.training_c_to_frames = {} self._setup_training_dict() if init: self.train()
def get_test_patches(video_name="Site 10.MP4", window=75, frame_num=10000): path_gp = p.get_path(p.KEY_GOPRO) fp2 = path_gp + video_name cap = create_capture(fp2) conv = VideoFrameConverter(cap) conv.set_current_frame(frame_num) return conv.get_frame_mxn_patches_list(window, window), conv.current_frame
def load_video(self): path = self.lbl_path.text() self.cap = create_capture(path) self.vid = VideoFrameConverter(self.cap) self.sld_pos.setRange(0, self.vid.num_frames) self.sld_pos.setValue(0) self.timer = QTimer(self) self.timer.timeout.connect(self._play) self.timer.start(27) self.update()
def __init__(self, video_src, output_dir, annotator, frameskip=None, existing_data=None): super(WVideoSubstrateGroundTruthing, self).__init__(None) self._capture = create_capture(video_src) self._frameskip = frameskip self._holder = GTMVideoSubstrates(self._capture, video_src, output_dir, annotator, existing_data) self._annotator = annotator self._frame_num = 0 self._frames_num_total = self._holder.converter.num_frames self._create_video_frame() self._playback_timer = QTimer(self) self._playback_speed = 27 self._playing = False self._frames_with_data = self._holder.frame_numbers_with_data self._classes_dict = {} # Layouts lyt_mid = QHBoxLayout() lyt_video = QVBoxLayout() lyt_video.setAlignment(Qt.AlignTop) lyt_video.addWidget(self._frm_video) lyt_video.addLayout(self._build_step_buttons()) lyt_mid.addLayout(lyt_video) lyt_mid.addWidget(self._build_classification_box()) lyt_btm = QHBoxLayout() lyt_main = QVBoxLayout() lyt_main.setMargin(10) lyt_main.setSpacing(10) lyt_main.setAlignment(Qt.AlignTop) lyt_main.addLayout(lyt_mid) lyt_main.addLayout(lyt_btm) widget = QWidget() widget.setLayout(lyt_main) self.setCentralWidget(widget) self.setWindowTitle(APP_NAME + " - " + self.STR_WIN_TITLE) self.update() self._show_next_frame()
def reset(self): self.trackers = HLDTrackers() self.cap = create_capture(self.video_src)
def setUp(self): path_gp = p.get_path(p.KEY_GOPRO) self.fp = path_gp + "Site 2.MP4" self.cap = create_capture(self.fp) self.conv = VideoFrameConverter(self.cap)