Skip to content

Commit fd77b95

Browse files
committed
review fixes: docstrings, fail-loud emplace, dead-code notes
Round of post-review polish on the backward-compat + dedup PRs. Correctness / fail-loud: - track_establishment_glomap.cc: THROW_CHECK on the two ProcessLoopClosurePairs tracks.emplace calls (track_id collision was previously silent). - track_filter_glomap.cc + track_establishment_glomap.cc: switch track.Elements().clear() -> track.SetElements({}) so the call survives a future signature drift on Elements() (review #7). Docstring / comment: - pycolmap motion_averaging.cc: random_seed binding doc now matches the new -1 default and surfaces the GP_SEED env-var escape at the Python boundary (review #1, #3). - global_positioning.h: header note on use_observation_exclusions clarifies that Image::is_excluded is itself fork-only; vanilla pycolmap users won't typically populate it (review #2). - rotation_averaging.h: prioritize_tracking_in_mst comment rephrased to describe gate semantics rather than videosfm wiring (the very coupling we just decoupled). - two_view_geometry_glomap.h: header explains FundamentalFromMotionAndCameras was a dead-code delete (no replacement migration), unlike the other 3 dropped helpers which got migrated to native (review #1 generic). - track_establishment_glomap.h: file-level note explaining why the glomap_ra namespace alias is kept post-collapse (binding-path stability — pycolmap submodule + videosfm import paths).
1 parent 182e447 commit fd77b95

7 files changed

Lines changed: 49 additions & 16 deletions

File tree

‎src/colmap/estimators/global_positioning.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ struct GlobalPositionerOptions {
7878
// ``AddObservationToProblem``. Default OFF preserves vanilla colmap4
7979
// behavior on Reconstructions that may carry stale exclusion flags.
8080
// videosfm sets true via ``_to_native_gp_options``.
81+
// Note: ``Image::is_excluded`` is itself a glomap-fork field (see
82+
// ``colmap/scene/image.h``). Vanilla pycolmap users won't typically
83+
// populate it; this gate exists so even when it IS populated (e.g.
84+
// by an external pipeline that copy-pasted the field name) the GP
85+
// residual count stays unchanged.
8186
bool use_observation_exclusions = false;
8287

8388
// Gate G-2 (GP-side LC config): when true, ``AddPoint3DToProblem``

‎src/colmap/estimators/rotation_averaging.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ struct RotationEstimatorOptions {
7878

7979
// Gate R-1: when true, ``ComputeMaximumPoseGraphSpanningTree`` penalizes
8080
// LC-dominated edges (subtracts kLCPenalty=1e9 from edge weight) so the
81-
// MST routes through tracking pairs first. Decoupled from
82-
// ``use_video_constraints`` (M10 was previously coupled to M11);
83-
// videosfm sets this true alongside ``use_video_constraints`` to keep
84-
// the existing combined behavior.
81+
// MST routes through tracking pairs first. Independent of
82+
// ``use_video_constraints`` and of ``skip_risky_LC_pairs``; pre-collapse
83+
// (M10) it was implicitly tied to ``use_video_constraints`` but is now
84+
// a separate knob — set independently of the Ceres-path opt-in.
8585
bool prioritize_tracking_in_mst = false;
8686

8787
// If true, switch from L1 + IRLS to a Ceres-based solver with differential

‎src/colmap/sfm/track_establishment_glomap.cc‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void TrackEngine::TrackCollection(
172172
for (const auto& feature : image_id_set.at(image_id)) {
173173
if ((feature - images_.at(image_id).features[feature_id]).norm() >
174174
options_.thres_inconsistency) {
175-
tracks[track_id].track.Elements().clear();
175+
tracks[track_id].track.SetElements({});
176176
break;
177177
}
178178
}
@@ -263,9 +263,18 @@ void TrackEngine::ProcessLoopClosurePairs(
263263
track_b.track.AddElement(image_id2, point2_idx);
264264
track_b.track.lc_elements.emplace_back(image_id1, point1_idx);
265265

266-
// Insert the new tracks
267-
tracks.emplace(tid_a, std::move(track_a));
268-
tracks.emplace(tid_b, std::move(track_b));
266+
// Insert the new tracks. Track ids derive from observation
267+
// (image_id, point2D_idx) pairs which must be unique post-MDRP;
268+
// assert no collision so a violation surfaces fast rather than
269+
// silently dropping a track.
270+
const auto inserted_a = tracks.emplace(tid_a, std::move(track_a));
271+
THROW_CHECK(inserted_a.second)
272+
<< "Track id collision on " << tid_a
273+
<< " — observation key reused unexpectedly";
274+
const auto inserted_b = tracks.emplace(tid_b, std::move(track_b));
275+
THROW_CHECK(inserted_b.second)
276+
<< "Track id collision on " << tid_b
277+
<< " — observation key reused unexpectedly";
269278

270279
// Register in lookup so subsequent LC pairs can find them
271280
obs_to_track[obs1_key] = tid_a;

‎src/colmap/sfm/track_establishment_glomap.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
#include <unordered_set>
1313

14+
// The ``colmap::glomap_ra`` namespace is kept post-collapse for binding-path
15+
// stability — pycolmap exposes these algorithms under a ``glomap_ra``
16+
// submodule (e.g. ``pycolmap.glomap_ra.filter_tracks_by_angle``) and the
17+
// videosfm callers depend on those import paths. The C++ types
18+
// underneath now reuse native colmap (``Point3D``/``Track``/``UnionFind``).
1419
namespace colmap {
1520
namespace glomap_ra {
1621
using ViewGraph = colmap::CorrespondenceGraph;

‎src/colmap/sfm/track_filter_glomap.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int TrackFilter::FilterTrackTriangulationAngle(
8787
// If the triangulation angle is too small, just remove it
8888
if (!status) {
8989
counter++;
90-
point3D.track.Elements().clear();
90+
point3D.track.SetElements({});
9191
}
9292
}
9393
LOG(INFO) << "Filtered " << counter << " / " << tracks.size()

‎src/colmap/sfm/two_view_geometry_glomap.h‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,22 @@
1313
// - SampsonError(E, Vec3, Vec3) (depth-aware variant — divides by z+EPS
1414
// before applying Sampson formula)
1515
//
16-
// Helpers that DID duplicate native (EssentialFromMotion, the Vec2 overload
17-
// of SampsonError, HomographyError, FundamentalFromMotionAndCameras) were
18-
// dropped in favor of colmap::EssentialMatrixFromPose,
19-
// colmap::ComputeSquaredSampsonError, colmap::ComputeSquaredHomographyError,
20-
// and colmap::FundamentalFromEssentialMatrix respectively.
16+
// Helpers that duplicated native were dropped:
17+
// - EssentialFromMotion -> use colmap::EssentialMatrixFromPose
18+
// (colmap/geometry/essential_matrix.h:83). Migrated callers in
19+
// image_pair_inliers_glomap.cc.
20+
// - SampsonError(E, Vec2, Vec2) -> use colmap::ComputeSquaredSampsonError
21+
// (colmap/geometry/essential_matrix.h:144) with .homogeneous()
22+
// conversion at the call site. Migrated callers in
23+
// image_pair_inliers_glomap.cc.
24+
// - HomographyError -> use colmap::ComputeSquaredHomographyError
25+
// (colmap/geometry/homography_matrix.h:110, note arg order is
26+
// (point1, point2, H)). Migrated callers in image_pair_inliers_glomap.cc.
27+
// - FundamentalFromMotionAndCameras was a 1-line wrapper with zero
28+
// call sites — pure dead-code delete (no migration needed). If a
29+
// future caller appears, build it inline as
30+
// ``FundamentalFromEssentialMatrix(K2, EssentialMatrixFromPose(pose), K1)``
31+
// from colmap/geometry/essential_matrix.h.
2132

2233
namespace colmap {
2334
namespace glomap_ra {

‎src/pycolmap/estimators/motion_averaging.cc‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ void BindGlobalPositioner(py::module& m) {
8787
"Minimum number of views per track.")
8888
.def_readwrite("random_seed",
8989
&GlobalPositionerOptions::random_seed,
90-
"PRNG seed for random initialization. -1 for "
91-
"non-deterministic. Default 1 for byte-identity.")
90+
"PRNG seed for random initialization. Default -1 "
91+
"(non-deterministic random_device, matches upstream "
92+
"colmap4). When -1 the ctor honors a GP_SEED env "
93+
"var as a documented escape for byte-identity "
94+
"recipes; set explicitly (>=0) to override.")
9295
.def_readwrite("loss_function_scale",
9396
&GlobalPositionerOptions::loss_function_scale,
9497
"Scaling factor for the loss function.")

0 commit comments

Comments
 (0)