def export_single(filename, cameras, camera_names, filenames): filenames = transpose_lists(filenames) data = struct(cameras=export_cameras(camera_names, cameras), image_sets=export_images(camera_names, filenames)) with open(filename, 'w') as outfile: json.dump(to_dicts(data), outfile, indent=2)
def calibration_points(boards, detections): board_detections = transpose_lists(detections) board_points = [board_correspondences(board, detections) for board, detections in zip(boards, board_detections)] return reduce(operator.add, board_points)
def export(filename, calib, names, filenames, master=None): if master is not None: calib = calib.with_master(master) camera_poses = calib.camera_poses.pose_table filenames = transpose_lists(filenames) data = struct( cameras = export_cameras(names.camera, calib.cameras), # camera_poses = export_sequential(names.camera, camera_poses), camera_poses = export_camera_poses(names.camera, camera_poses)\ if master is None else export_relative(names.camera, camera_poses, master), image_sets = export_images(names.camera, filenames) ) with open(filename, 'w') as outfile: json.dump(to_dicts(data), outfile, indent=2)
def calibrate_cameras(boards, points, image_sizes, **kwargs): with ThreadPool() as pool: f = partial(Camera.calibrate, boards, **kwargs) return transpose_lists(pool.starmap(f, zip(points, image_sizes)))