Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding glomap support to ns-process-data, works with COLMAP 3.8! #3409

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ColmapConverterToNerfstudioDataset(BaseConverterToNerfstudioDataset):
"""Feature matching method to use. Vocab tree is recommended for a balance of speed
and accuracy. Exhaustive is slower but more accurate. Sequential is faster but
should only be used for videos."""
sfm_tool: Literal["any", "colmap", "hloc"] = "any"
sfm_tool: Literal["any", "colmap", "glomap", "hloc"] = "any"
"""Structure from motion tool to use. Colmap will use sift features, hloc can use
many modern methods such as superpoint features and superglue matcher"""
refine_pixsfm: bool = False
Expand Down Expand Up @@ -222,6 +222,19 @@ def _run_colmap(self, mask_path: Optional[Path] = None):
refine_intrinsics=self.refine_intrinsics,
colmap_cmd=self.colmap_cmd,
)
elif sfm_tool == "glomap":
colmap_utils.run_colmap(
image_dir=image_dir,
colmap_dir=self.absolute_colmap_path,
camera_model=CAMERA_MODELS[self.camera_type],
camera_mask_path=mask_path,
gpu=self.gpu,
verbose=self.verbose,
matching_method=self.matching_method,
refine_intrinsics=self.refine_intrinsics,
colmap_cmd=self.colmap_cmd,
glomap_toggle=True,
)
elif sfm_tool == "hloc":
if mask_path is not None:
raise RuntimeError("Cannot use a mask with hloc. Please remove the cropping options " "and try again.")
Expand Down
21 changes: 15 additions & 6 deletions nerfstudio/process_data/colmap_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
matching_method: Literal["vocab_tree", "exhaustive", "sequential"] = "vocab_tree",
refine_intrinsics: bool = True,
colmap_cmd: str = "colmap",
glomap_toggle: bool = False,
) -> None:
"""Runs COLMAP on the images.

Expand Down Expand Up @@ -153,12 +154,20 @@
# Bundle adjustment
sparse_dir = colmap_dir / "sparse"
sparse_dir.mkdir(parents=True, exist_ok=True)
mapper_cmd = [
f"{colmap_cmd} mapper",
f"--database_path {colmap_dir / 'database.db'}",
f"--image_path {image_dir}",
f"--output_path {sparse_dir}",
]
if glomap_toggle:
mapper_cmd = [
AntonioMacaronio marked this conversation as resolved.
Show resolved Hide resolved
f"glomap mapper",

Check failure on line 159 in nerfstudio/process_data/colmap_utils.py

View workflow job for this annotation

GitHub Actions / build

Ruff (F541)

nerfstudio/process_data/colmap_utils.py:159:13: F541 f-string without any placeholders
f"--database_path {colmap_dir / 'database.db'}",
f"--image_path {image_dir}",
f"--output_path {sparse_dir}",
]
else:
mapper_cmd = [
f"{colmap_cmd} mapper",
f"--database_path {colmap_dir / 'database.db'}",
f"--image_path {image_dir}",
f"--output_path {sparse_dir}",
]
if colmap_version >= Version("3.7"):
mapper_cmd.append("--Mapper.ba_global_function_tolerance=1e-6")

Expand Down
Loading