Skip to content

Commit

Permalink
update convert and demo_sfm
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunxiang Lu committed Mar 10, 2024
1 parent 801d79d commit cb8bcef
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions convert_bin_to_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import pycolmap

reconstruction = pycolmap.Reconstruction("outputs/demo/sfm")
print(reconstruction.summary())

# convert .bin file to .txt file
reconstruction.write_text("outputs/demo/sfm") # text format
reconstruction.export_PLY("outputs/demo/sfm/rec.ply") # PLY format
32 changes: 32 additions & 0 deletions demo_sfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,35 @@
pairs_from_retrieval,
)

# define path
images = Path("datasets/South-Building/images/")

outputs = Path("outputs/sfm_south/")
sfm_pairs = outputs / "pairs-netvlad.txt"
sfm_dir = outputs / "sfm_superpoint+superglue"

retrieval_conf = extract_features.confs["netvlad"]
feature_conf = extract_features.confs["superpoint_aachen"]
matcher_conf = match_features.confs["superglue"]

# find image pairs via image retrieval
# We extract global descriptors with NetVLAD and find for each image the most similar ones.

# netvlad process each image and output a 4096 dim global descriptor vector
retrieval_path = extract_features.main(retrieval_conf, images, outputs)
pairs_from_retrieval.main(retrieval_path, sfm_pairs, num_matched=5)

# extract and match local features
feature_path = extract_features.main(feature_conf, images, outputs)
match_path = match_features.main(
matcher_conf, sfm_pairs, feature_conf["output"], outputs
)

# run colmap on the features and matches
model = reconstruction.main(sfm_dir, images, sfm_pairs, feature_path, match_path)

# model.write_text("./") # text format
model.export_PLY(outputs / "scene.ply") # PLY format

# visualize
visualization.visualize_sfm_2d(model, images, color_by="visibility", n=5)

0 comments on commit cb8bcef

Please sign in to comment.