Skip to content

Commit

Permalink
use pycolmap for colmap runner
Browse files Browse the repository at this point in the history
  • Loading branch information
B1ueber2y committed Nov 29, 2024
1 parent 64f35dc commit 2cc1a45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
1 change: 1 addition & 0 deletions limap/base/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def align_imagecols_colmap(
f.write(f"{imname} {pos[0]} {pos[1]} {pos[2]}\n")

# call comlap model aligner
# TODO: use pycolmap
transform_path = os.path.join(tmp_folder, "transform.txt")
cmd = [
"colmap",
Expand Down
31 changes: 6 additions & 25 deletions limap/pointsfm/colmap_sfm.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import copy
import os
import shutil
import subprocess
import sys
from pathlib import Path

import cv2
import pycolmap
from pycolmap import logging

sys.path.append(os.path.dirname(os.path.abspath(__file__)))
Expand Down Expand Up @@ -193,17 +193,7 @@ def run_colmap_sfm(
)

### [COLMAP] mapper
cmd = [
"colmap",
"mapper",
"--database_path",
db_path,
"--image_path",
image_path,
"--output_path",
model_path,
]
subprocess.run(cmd, check=True)
pycolmap.incremental_mapping(db_path, image_path, model_path)

# map to original image names
if map_to_original_image_names:
Expand Down Expand Up @@ -273,19 +263,10 @@ def run_colmap_sfm_with_known_poses(

### [COLMAP] point triangulation
# point triangulation
cmd = [
"colmap",
"point_triangulator",
"--database_path",
db_path,
"--image_path",
image_path,
"--input_path",
model_path,
"--output_path",
point_triangulation_path,
]
subprocess.run(cmd, check=True)
input_reconstruction = pycolmap.Reconstruction(model_path)
pycolmap.triangulate_points(
input_reconstruction, db_path, image_path, point_triangulation_path
)

# map to original image names
if map_to_original_image_names:
Expand Down

0 comments on commit 2cc1a45

Please sign in to comment.