mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-07 00:09:14 +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:
|
services:
|
||||||
nerfstudio:
|
nerfstudio:
|
||||||
shm_size: '12gb'
|
shm_size: '12gb'
|
||||||
image: dromni/nerfstudio:0.1.18
|
image: nerfstudio:latest
|
||||||
# build:
|
build:
|
||||||
# context: ..
|
context: ..
|
||||||
# dockerfile: ./Dockerfile
|
dockerfile: ./Dockerfile
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
+14
@@ -34,6 +34,7 @@ RUN apt-get update && \
|
|||||||
libboost-program-options-dev \
|
libboost-program-options-dev \
|
||||||
libboost-system-dev \
|
libboost-system-dev \
|
||||||
libboost-test-dev \
|
libboost-test-dev \
|
||||||
|
libhdf5-dev \
|
||||||
libcgal-dev \
|
libcgal-dev \
|
||||||
libeigen3-dev \
|
libeigen3-dev \
|
||||||
libflann-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 . && \
|
python3.10 -m pip install -e . && \
|
||||||
cd ..
|
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.
|
# Copy nerfstudio folder and give ownership to user.
|
||||||
ADD . /home/user/nerfstudio
|
ADD . /home/user/nerfstudio
|
||||||
USER root
|
USER root
|
||||||
|
|||||||
@@ -42,6 +42,13 @@ except ImportError:
|
|||||||
else:
|
else:
|
||||||
_HAS_HLOC = True
|
_HAS_HLOC = True
|
||||||
|
|
||||||
|
try:
|
||||||
|
from pixsfm.refine_hloc import PixSfM
|
||||||
|
except ImportError:
|
||||||
|
_HAS_PIXSFM = False
|
||||||
|
else:
|
||||||
|
_HAS_PIXSFM = True
|
||||||
|
|
||||||
CONSOLE = Console(width=120)
|
CONSOLE = Console(width=120)
|
||||||
|
|
||||||
|
|
||||||
@@ -58,6 +65,7 @@ def run_hloc(
|
|||||||
"superglue", "superglue-fast", "NN-superpoint", "NN-ratio", "NN-mutual", "adalam"
|
"superglue", "superglue-fast", "NN-superpoint", "NN-ratio", "NN-mutual", "adalam"
|
||||||
] = "superglue",
|
] = "superglue",
|
||||||
num_matched: int = 50,
|
num_matched: int = 50,
|
||||||
|
refine_pixsfm: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Runs hloc on the images.
|
"""Runs hloc on the images.
|
||||||
|
|
||||||
@@ -75,6 +83,10 @@ def run_hloc(
|
|||||||
)
|
)
|
||||||
sys.exit(1)
|
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
|
outputs = colmap_dir
|
||||||
sfm_pairs = outputs / "pairs-netvlad.txt"
|
sfm_pairs = outputs / "pairs-netvlad.txt"
|
||||||
sfm_dir = outputs / "sparse" / "0"
|
sfm_dir = outputs / "sparse" / "0"
|
||||||
@@ -99,13 +111,29 @@ def run_hloc(
|
|||||||
image_options = pycolmap.ImageReaderOptions( # pylint: disable=c-extension-no-member
|
image_options = pycolmap.ImageReaderOptions( # pylint: disable=c-extension-no-member
|
||||||
camera_model=camera_model.value
|
camera_model=camera_model.value
|
||||||
)
|
)
|
||||||
reconstruction.main(
|
if refine_pixsfm:
|
||||||
sfm_dir,
|
sfm = PixSfM({"dense_features": {"max_edge": 1024}})
|
||||||
image_dir,
|
refined, _ = sfm.reconstruction(
|
||||||
sfm_pairs,
|
sfm_dir,
|
||||||
features,
|
image_dir,
|
||||||
matches,
|
sfm_pairs,
|
||||||
camera_mode=pycolmap.CameraMode.SINGLE, # pylint: disable=c-extension-no-member
|
features,
|
||||||
image_options=image_options,
|
matches,
|
||||||
verbose=verbose,
|
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"
|
sfm_tool: Literal["any", "colmap", "hloc"] = "any"
|
||||||
"""Structure from motion tool to use. Colmap will use sift features, hloc can use many modern methods
|
"""Structure from motion tool to use. Colmap will use sift features, hloc can use many modern methods
|
||||||
such as superpoint features and superglue matcher"""
|
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[
|
feature_type: Literal[
|
||||||
"any",
|
"any",
|
||||||
"sift",
|
"sift",
|
||||||
@@ -211,6 +213,9 @@ class ProcessImages:
|
|||||||
(sfm_tool, feature_type, matcher_type) = process_data_utils.find_tool_feature_matcher_combination(
|
(sfm_tool, feature_type, matcher_type) = process_data_utils.find_tool_feature_matcher_combination(
|
||||||
self.sfm_tool, self.feature_type, self.matcher_type
|
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":
|
if sfm_tool == "colmap":
|
||||||
colmap_utils.run_colmap(
|
colmap_utils.run_colmap(
|
||||||
|
|||||||
Reference in new issue
Block a user