As part of run_reconstruction, the data for images.bin, cameras.bin, and points3D.bin for the largest reconstruction is supposed to be moved to sfm_dir. However, this does not happen reliably when COLMAP produces multiple models.
This is because the models in the numbered folders created by COLMAP (models/0, models/1, etc.) are not guaranteed to be in the same order as the reconstructions list returned by COLMAP.
As part of
run_reconstruction
, the data forimages.bin
,cameras.bin
, andpoints3D.bin
for the largest reconstruction is supposed to be moved tosfm_dir
. However, this does not happen reliably when COLMAP produces multiple models.This is because the models in the numbered folders created by COLMAP (
models/0
,models/1
, etc.) are not guaranteed to be in the same order as thereconstructions
list returned by COLMAP.COLMAP numbers the folders based on the count of
points3D
so that the folder0
always has the model with the largest number of points and this is different than the order of thereconstructions
list: https://github.com/colmap/colmap/blob/db14f5c59bdaa5239b804ff4623f2fb8e5bb2a46/src/colmap/scene/reconstruction_manager.cc#L60-L83This difference causes an issue in
run_reconstruction
where the data that is moved does not correspond to the model of thelargest_index
:https://github.com/cvg/Hierarchical-Localization/blob/b21ff203ead5a3257df3b6806214ff605e0c01c5/hloc/reconstruction.py#L99-L103
Forcing
largest_index
to always be0
resolves the issue, but is different behavior than before.It looks like this issue was introduced as part of hloc 1.3 because before hloc 1.3, the logic involved iterating directly over the model folders https://github.com/cvg/Hierarchical-Localization/commit/55e6cde6d3b98cd97c3e48aef02f40e1f4fe3875#diff-1415a09ff92c2b9e2091340b072a454b63b9b7422a63f363dc6c2dcce7349769:
https://github.com/cvg/Hierarchical-Localization/blob/9bad6b46466fae34f1d6215c911e19b5a2e24dea/hloc/reconstruction.py#L81-L96