Skip to content

Commit

Permalink
Only import pycolmap in run_hloc (#3146)
Browse files Browse the repository at this point in the history
* remove pycolmap import on windows

* only import when run hloc

* also for pixsfm

* fix
  • Loading branch information
KevinXu02 committed May 15, 2024
1 parent dd811f5 commit e6d780d
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions nerfstudio/process_data/hloc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,6 @@
from nerfstudio.process_data.process_data_utils import CameraModel
from nerfstudio.utils.rich_utils import CONSOLE

try:
# TODO(1480) un-hide pycolmap import
import pycolmap
from hloc import ( # type: ignore
extract_features,
match_features,
pairs_from_exhaustive,
pairs_from_retrieval,
reconstruction,
)
except ImportError:
_HAS_HLOC = False

else:
_HAS_HLOC = True

try:
from pixsfm.refine_hloc import PixSfM # type: ignore
except ImportError:
_HAS_PIXSFM = False
else:
_HAS_PIXSFM = True


def run_hloc(
image_dir: Path,
Expand Down Expand Up @@ -88,6 +65,29 @@ def run_hloc(
refine_pixsfm: If True, refine the reconstruction using pixel-perfect-sfm.
use_single_camera_mode: If True, uses one camera for all frames. Otherwise uses one camera per frame.
"""

try:
# TODO(1480) un-hide pycolmap import
import pycolmap
from hloc import ( # type: ignore
extract_features,
match_features,
pairs_from_exhaustive,
pairs_from_retrieval,
reconstruction,
)
except ImportError:
_HAS_HLOC = False
else:
_HAS_HLOC = True

try:
from pixsfm.refine_hloc import PixSfM # type: ignore
except ImportError:
_HAS_PIXSFM = False
else:
_HAS_PIXSFM = True

if not _HAS_HLOC:
CONSOLE.print(
f"[bold red]Error: To use this set of parameters ({feature_type}/{matcher_type}/hloc), "
Expand Down

0 comments on commit e6d780d

Please sign in to comment.