mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-21 07:05:44 +08:00
Add option to use Pixel Perfect SFM (#1554)
add pixsfm option when using hloc
This commit is contained in:
1 parent
ddfa463f4d
commit
630babacd6
4 files changed
+61
-14
No files matched your search
@@ -42,6 +42,13 @@ except ImportError:
|
||||
else:
|
||||
_HAS_HLOC = True
|
||||
|
||||
try:
|
||||
from pixsfm.refine_hloc import PixSfM
|
||||
except ImportError:
|
||||
_HAS_PIXSFM = False
|
||||
else:
|
||||
_HAS_PIXSFM = True
|
||||
|
||||
CONSOLE = Console(width=120)
|
||||
|
||||
|
||||
@@ -58,6 +65,7 @@ def run_hloc(
|
||||
"superglue", "superglue-fast", "NN-superpoint", "NN-ratio", "NN-mutual", "adalam"
|
||||
] = "superglue",
|
||||
num_matched: int = 50,
|
||||
refine_pixsfm: bool = False,
|
||||
) -> None:
|
||||
"""Runs hloc on the images.
|
||||
|
||||
@@ -75,6 +83,10 @@ def run_hloc(
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
if refine_pixsfm and not _HAS_PIXSFM:
|
||||
CONSOLE.print("[bold red]Error: use refine_pixsfm, you must install pixel-perfect-sfm toolbox!!")
|
||||
sys.exit(1)
|
||||
|
||||
outputs = colmap_dir
|
||||
sfm_pairs = outputs / "pairs-netvlad.txt"
|
||||
sfm_dir = outputs / "sparse" / "0"
|
||||
@@ -99,13 +111,29 @@ def run_hloc(
|
||||
image_options = pycolmap.ImageReaderOptions( # pylint: disable=c-extension-no-member
|
||||
camera_model=camera_model.value
|
||||
)
|
||||
reconstruction.main(
|
||||
sfm_dir,
|
||||
image_dir,
|
||||
sfm_pairs,
|
||||
features,
|
||||
matches,
|
||||
camera_mode=pycolmap.CameraMode.SINGLE, # pylint: disable=c-extension-no-member
|
||||
image_options=image_options,
|
||||
verbose=verbose,
|
||||
)
|
||||
if refine_pixsfm:
|
||||
sfm = PixSfM({"dense_features": {"max_edge": 1024}})
|
||||
refined, _ = sfm.reconstruction(
|
||||
sfm_dir,
|
||||
image_dir,
|
||||
sfm_pairs,
|
||||
features,
|
||||
matches,
|
||||
image_list=references,
|
||||
camera_mode=pycolmap.CameraMode.SINGLE, # pylint: disable=c-extension-no-member
|
||||
image_options=image_options,
|
||||
verbose=verbose,
|
||||
)
|
||||
print("Refined", refined.summary())
|
||||
|
||||
else:
|
||||
reconstruction.main(
|
||||
sfm_dir,
|
||||
image_dir,
|
||||
sfm_pairs,
|
||||
features,
|
||||
matches,
|
||||
camera_mode=pycolmap.CameraMode.SINGLE, # pylint: disable=c-extension-no-member
|
||||
image_options=image_options,
|
||||
verbose=verbose,
|
||||
)
|
||||
Reference in new issue
Block a user