def gather_frame_data(self):
        self.object_points = []
        print("Gathering frame data...")

        if self.args.load_frame_data:
            self.board_object_corner_set = \
                cio.load_frame_data(self.aux_data_file, self.videos, self.board_dims[0], self.board_dims[1],
                                    self.args.board_square_size)

            usable_frame_ct = len(self.videos[0].image_points)

            for i_frame in range(usable_frame_ct):  # @UnusedVariable
                self.object_points.append(self.board_object_corner_set)

        else:
            if self.args.load_images:
                usable_frame_ct = self.load_frame_images()
            elif self.args.frame_count_target != -1:
                usable_frame_ct = self.run_capture_deterministic_count()
            else:
                usable_frame_ct = self.run_capture()
            if self.args.save_frame_data:
                cio.save_frame_data(
                    self.aux_data_file,
                    os.path.join(self.args.folder, self.args.aux_data_file),
                    self.videos, self.board_object_corner_set)

        print("Total usable frames: {0:d} ({1:.3%})".format(
            usable_frame_ct,
            float(usable_frame_ct) / self.total_frames))
        self.usable_frame_count = usable_frame_ct
示例#2
0
    def gather_frame_data(self):
        self.object_points = []
        print("Gathering frame data...")

        if self.args.load_frame_data:
            self.board_object_corner_set = \
                cio.load_frame_data(self.aux_data_file, self.videos, self.board_dims[0], self.board_dims[1],
                                    self.args.board_square_size)

            usable_frame_ct = len(self.videos[0].image_points)

            for i_frame in range(usable_frame_ct):  # @UnusedVariable
                self.object_points.append(self.board_object_corner_set)

        else:
            if self.args.load_images:
                usable_frame_ct = self.load_frame_images()
            elif self.args.frame_count_target != -1:
                usable_frame_ct = self.run_capture_deterministic_count()
            else:
                usable_frame_ct = self.run_capture()
            if self.args.save_frame_data:
                cio.save_frame_data(self.aux_data_file, os.path.join(self.args.folder, self.args.aux_data_file),
                                    self.videos, self.board_object_corner_set)

        print("Total usable frames: {0:d} ({1:.3%})"
              .format(usable_frame_ct, float(usable_frame_ct) / self.total_frames))
        self.usable_frame_count = usable_frame_ct
示例#3
0
    def gather_frame_data(self, verbose=True):
        if self.args.load_calibration_intervals:
            cio.load_calibration_intervals(self.aux_data_file,
                                           self.cameras,
                                           verbose=verbose)
        else:
            if self.args.use_all_frames:
                min_fc = sys.maxsize
                for camera in self.cameras:
                    if camera.frame_count < min_fc:
                        min_fc = camera.frame_count
                for camera in self.cameras:
                    camera.calibration_interval = (0, min_fc)
            else:
                self.find_calibration_intervals(verbose)

        if self.args.load_frame_data:
            self.board_object_corner_set = cio.load_frame_data(
                self.aux_data_file, self.cameras, verbose=verbose)
            if verbose:
                for camera in self.cameras:
                    max_rms = 0.0
                    min_rms = float(sys.maxsize)
                    object_points = self.board_object_corner_set
                    cum_rms = 0.0
                    for i_usable_frame in range(0, len(camera.poses)):
                        rms = camera.find_reprojection_error(
                            i_usable_frame, object_points)
                        # if ... elif ... min/max tracking only works for cases with > 1 usable frame
                        if rms > max_rms:
                            max_rms = rms
                        elif rms < min_rms:
                            min_rms = rms
                        cum_rms += rms
                    print(
                        "AVE, MIN, MAX RMS for camera {:s} : {:.4f}, {:.4f}, {:.4f}"
                        .format(camera.name, cum_rms / len(camera.poses),
                                min_rms, max_rms))

        else:
            self.run_capture(verbose)
            # self.find_camera_poses(verbose)
            if self.args.save_frame_data:
                cio.save_frame_data(
                    self.aux_data_file,
                    os.path.join(self.args.folder, self.args.aux_data_file),
                    self.cameras, self.board_object_corner_set)
示例#4
0
    def gather_frame_data(self, verbose=True):
        if self.args.load_calibration_intervals:
            cio.load_calibration_intervals(self.aux_data_file, self.cameras, verbose=verbose)
        else:
            if self.args.use_all_frames:
                min_fc = sys.maxsize
                for camera in self.cameras:
                    if camera.frame_count < min_fc:
                        min_fc = camera.frame_count
                for camera in self.cameras:
                    camera.calibration_interval = (0, min_fc)
            else:
                self.find_calibration_intervals(verbose)

        if self.args.load_frame_data:
            self.board_object_corner_set = cio.load_frame_data(self.aux_data_file, self.cameras,
                                                               verbose=verbose)
            if verbose:
                for camera in self.cameras:
                    max_rms = 0.0
                    min_rms = float(sys.maxsize)
                    object_points = self.board_object_corner_set
                    cum_rms = 0.0
                    for i_usable_frame in range(0, len(camera.poses)):
                        rms = camera.find_reprojection_error(i_usable_frame, object_points)
                        # if ... elif ... min/max tracking only works for cases with > 1 usable frame
                        if rms > max_rms:
                            max_rms = rms
                        elif rms < min_rms:
                            min_rms = rms
                        cum_rms += rms
                    print("AVE, MIN, MAX RMS for camera {:s} : {:.4f}, {:.4f}, {:.4f}"
                          .format(camera.name, cum_rms / len(camera.poses), min_rms, max_rms))

        else:
            self.run_capture(verbose)
            # self.find_camera_poses(verbose)
            if self.args.save_frame_data:
                cio.save_frame_data(self.aux_data_file, os.path.join(self.args.folder, self.args.aux_data_file),
                                    self.cameras,
                                    self.board_object_corner_set)