(
args: argparse.Namespace,
scene_info: SceneInfo,
prepare_scene: Callable[[SceneInfo], None],
position_accuracy_gt: float,
num_threads: int,
gpu_index: str = "-1",
progress_status=None,
)
| 682 | |
| 683 | |
| 684 | def process_scene( |
| 685 | args: argparse.Namespace, |
| 686 | scene_info: SceneInfo, |
| 687 | prepare_scene: Callable[[SceneInfo], None], |
| 688 | position_accuracy_gt: float, |
| 689 | num_threads: int, |
| 690 | gpu_index: str = "-1", |
| 691 | progress_status=None, |
| 692 | ) -> SceneResult: |
| 693 | pycolmap.logging.info( |
| 694 | f"Processing dataset={scene_info.dataset}, " |
| 695 | f"category={scene_info.category}, " |
| 696 | f"scene={scene_info.scene}" |
| 697 | ) |
| 698 | |
| 699 | tracker = _PhaseTracker(progress_status, _scene_key(scene_info)) |
| 700 | |
| 701 | tracker.set("setup") |
| 702 | prepare_scene(scene_info) |
| 703 | |
| 704 | sparse_gt = pycolmap.Reconstruction(str(scene_info.sparse_gt_path)) |
| 705 | |
| 706 | colmap_reconstruction( |
| 707 | args=args, |
| 708 | workspace_path=scene_info.workspace_path, |
| 709 | image_path=scene_info.image_path, |
| 710 | camera_priors_sparse_gt=( |
| 711 | sparse_gt |
| 712 | if not args.uncalibrated and scene_info.has_camera_priors |
| 713 | else None |
| 714 | ), |
| 715 | covisibility_sparse_gt=( |
| 716 | sparse_gt if args.filter_covisibility else None |
| 717 | ), |
| 718 | num_threads=num_threads, |
| 719 | colmap_extra_args=scene_info.colmap_extra_args, |
| 720 | gpu_index=gpu_index, |
| 721 | phase_tracker=tracker, |
| 722 | ) |
| 723 | |
| 724 | tracker.set("evaluation") |
| 725 | |
| 726 | # Merge all sub-models into a single reconstruction. Each sub-model will be |
| 727 | # "randomly" aligned to the other sub-models. We then compute the overall |
| 728 | # error over the merged reconstruction. With this simple appraoch, there is |
| 729 | # a small chance that the randomly aligned images in one sub-model are |
| 730 | # correctly aligned with other sub-models and the error is therefore |
| 731 | # underestimated. However, this is very unlikely to happen. |
| 732 | sparse_merged = pycolmap.Reconstruction() |
| 733 | num_components = 0 |
| 734 | largest_component = 0 |
| 735 | for sparse_path in (scene_info.workspace_path / "sparse").iterdir(): |
| 736 | if not sparse_path.is_dir(): |
| 737 | continue |
| 738 | num_components += 1 |
| 739 | sparse = None |
| 740 | if args.error_type.startswith("relative"): |
| 741 | sparse = pycolmap.Reconstruction(str(sparse_path)) |
no test coverage detected