diff --git a/nerfstudio/process_data/colmap_converter_to_nerfstudio_dataset.py b/nerfstudio/process_data/colmap_converter_to_nerfstudio_dataset.py index 7ab711b46..b4dccbdd8 100644 --- a/nerfstudio/process_data/colmap_converter_to_nerfstudio_dataset.py +++ b/nerfstudio/process_data/colmap_converter_to_nerfstudio_dataset.py @@ -41,6 +41,9 @@ class ColmapConverterToNerfstudioDataset(BaseConverterToNerfstudioDataset): refine_pixsfm: bool = False """If True, runs refinement using Pixel Perfect SFM. Only works with hloc sfm_tool""" + refine_intrinsics: bool = True + """If True, do bundle adjustment to refine intrinsics. + Only works with colmap sfm_tool""" feature_type: Literal[ "any", "sift", @@ -204,6 +207,7 @@ class ColmapConverterToNerfstudioDataset(BaseConverterToNerfstudioDataset): gpu=self.gpu, verbose=self.verbose, matching_method=self.matching_method, + refine_intrinsics=self.refine_intrinsics, colmap_cmd=self.colmap_cmd, ) elif sfm_tool == "hloc": diff --git a/nerfstudio/process_data/colmap_utils.py b/nerfstudio/process_data/colmap_utils.py index 2322075b5..83188c005 100644 --- a/nerfstudio/process_data/colmap_utils.py +++ b/nerfstudio/process_data/colmap_utils.py @@ -93,6 +93,7 @@ def run_colmap( gpu: bool = True, verbose: bool = False, matching_method: Literal["vocab_tree", "exhaustive", "sequential"] = "vocab_tree", + refine_intrinsics: bool = True, colmap_cmd: str = "colmap", ) -> None: """Runs COLMAP on the images. @@ -105,6 +106,7 @@ def run_colmap( gpu: If True, use GPU. verbose: If True, logs the output of the command. matching_method: Matching method to use. + refine_intrinsics: If True, refine intrinsics. colmap_cmd: Path to the COLMAP executable. """ @@ -154,7 +156,7 @@ def run_colmap( f"--output_path {sparse_dir}", ] if colmap_version >= 3.7: - mapper_cmd.append("--Mapper.ba_global_function_tolerance 1e-6") + mapper_cmd.append("--Mapper.ba_global_function_tolerance=1e-6") mapper_cmd = " ".join(mapper_cmd) @@ -165,15 +167,17 @@ def run_colmap( ): run_command(mapper_cmd, verbose=verbose) CONSOLE.log("[bold green]:tada: Done COLMAP bundle adjustment.") - with status(msg="[bold yellow]Refine intrinsics...", spinner="dqpb", verbose=verbose): - bundle_adjuster_cmd = [ - f"{colmap_cmd} bundle_adjuster", - f"--input_path {sparse_dir}/0", - f"--output_path {sparse_dir}/0", - "--BundleAdjustment.refine_principal_point 1", - ] - run_command(" ".join(bundle_adjuster_cmd), verbose=verbose) - CONSOLE.log("[bold green]:tada: Done refining intrinsics.") + + if refine_intrinsics: + with status(msg="[bold yellow]Refine intrinsics...", spinner="dqpb", verbose=verbose): + bundle_adjuster_cmd = [ + f"{colmap_cmd} bundle_adjuster", + f"--input_path {sparse_dir}/0", + f"--output_path {sparse_dir}/0", + "--BundleAdjustment.refine_principal_point 1", + ] + run_command(" ".join(bundle_adjuster_cmd), verbose=verbose) + CONSOLE.log("[bold green]:tada: Done refining intrinsics.") def parse_colmap_camera_params(camera) -> Dict[str, Any]: