mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-18 13:53: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
@@ -3,10 +3,10 @@ version: "3.8"
|
||||
services:
|
||||
nerfstudio:
|
||||
shm_size: '12gb'
|
||||
image: dromni/nerfstudio:0.1.18
|
||||
# build:
|
||||
# context: ..
|
||||
# dockerfile: ./Dockerfile
|
||||
image: nerfstudio:latest
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: ./Dockerfile
|
||||
stdin_open: true
|
||||
tty: true
|
||||
environment:
|
||||
|
||||
+14
@@ -34,6 +34,7 @@ RUN apt-get update && \
|
||||
libboost-program-options-dev \
|
||||
libboost-system-dev \
|
||||
libboost-test-dev \
|
||||
libhdf5-dev \
|
||||
libcgal-dev \
|
||||
libeigen3-dev \
|
||||
libflann-dev \
|
||||
@@ -132,6 +133,19 @@ RUN git clone --branch master --recursive https://github.com/cvg/Hierarchical-Lo
|
||||
python3.10 -m pip install -e . && \
|
||||
cd ..
|
||||
|
||||
# Install pyceres from source
|
||||
RUN git clone --branch main --recursive https://github.com/cvg/pyceres.git && \
|
||||
cd pyceres && \
|
||||
python3.10 -m pip install -e . && \
|
||||
cd ..
|
||||
|
||||
# Install pixel perfect sfm.
|
||||
RUN git clone --branch main --recursive https://github.com/cvg/pixel-perfect-sfm && \
|
||||
cd pixel-perfect-sfm && \
|
||||
python3.10 -m pip install -e . && \
|
||||
cd ..
|
||||
|
||||
RUN python3.10 -m pip install omegaconf
|
||||
# Copy nerfstudio folder and give ownership to user.
|
||||
ADD . /home/user/nerfstudio
|
||||
USER root
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
@@ -55,6 +55,8 @@ class ProcessImages:
|
||||
sfm_tool: Literal["any", "colmap", "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
|
||||
"""If True, runs refinement using Pixel Perfect SFM. Only works with hloc sfm_tool"""
|
||||
feature_type: Literal[
|
||||
"any",
|
||||
"sift",
|
||||
@@ -211,6 +213,9 @@ class ProcessImages:
|
||||
(sfm_tool, feature_type, matcher_type) = process_data_utils.find_tool_feature_matcher_combination(
|
||||
self.sfm_tool, self.feature_type, self.matcher_type
|
||||
)
|
||||
# check that sfm_tool is hloc if using refine_pixsfm
|
||||
if self.refine_pixsfm:
|
||||
assert sfm_tool == "hloc", "refine_pixsfm only works with sfm_tool hloc"
|
||||
|
||||
if sfm_tool == "colmap":
|
||||
colmap_utils.run_colmap(
|
||||
|
||||
Reference in new issue
Block a user