Beispiel #1
0
    def run(self):
        """Function executed when the current thread is created."""
        if self.processing_frame_id is None:
            Logger.error("Processing frame id is None!")
            return
        if self.processing_frame is None:
            Logger.error("Processing frame is None")
            return

        Logger.debug("Processing frame id {}".format(self.processing_frame_id))
        self.app.step(self.processing_frame_id, self.processing_frame)

        self.last_frame_signal.emit(self.app.last_scaled_frame_rgb)
        self.module_list_signal.emit(self.app.create_module_list())

        self.app.reset()
Beispiel #2
0
    def __load_video(self, video_raw: cv2.VideoCapture):
        if not video_raw.isOpened():
            Logger.error("Unable to read {} feed".format(self.video_path))

        self.frames = []

        num_video_frames = int(video_raw.get(cv2.CAP_PROP_FRAME_COUNT))
        if self.end_frame is None or self.end_frame > num_video_frames:
            Logger.warning("Setting end_frame to {}".format(num_video_frames))
            self.end_frame = num_video_frames

        num_frames = 0

        # Skip the first frames until the self_start frame.
        video_raw.set(cv2.CAP_PROP_POS_FRAMES, self.start_frame)

        Logger.info("Loading {} frames...".format(self.end_frame -
                                                  self.start_frame))
        bar = progressbar.ProgressBar(maxval=self.num_frames,
                                      widgets=[
                                          progressbar.Bar('=', '[', ']'), ' ',
                                          progressbar.Percentage()
                                      ])
        bar.start()
        for i in range(self.end_frame - self.start_frame):
            ret = video_raw.grab()
            if not ret:
                Logger.error(
                    "Could not load frame {}".format(i + self.start_frame))
                raise ValueError(
                    "Could not load frame {}".format(i + self.start_frame))

            self.frames.append(video_raw.retrieve()[1])
            num_frames += 1
            bar.update(num_frames)

        bar.finish()
        video_raw.release()