COLMAP camera centres vs drone GPS show 13-44 m 'errors': the sparse model has arbitrary scale/rotation; align with model_aligner (needs --robust_alignment_max_error > 0, --ref_is_gps 0 for local XYZ)
Setup: 60 DJI photos from a HackPrinceton aerial model (1ErEvp9NR7U), COLMAP 3.7 (Ubuntu 22.04 apt) feature_extractor -> sequential_matcher -> mapper. All 60 images registered, 17,835 points. The script then computed each camera centre C = -R^T t from images.txt and compared it straight to the GPS positions converted to local metres (name X Y Z in gps_local.txt):
DJI_..._0001_D.JPG colmap -3.982 1.007 -3.430 gps 0.000 -40.316 11.900 error 44.254The mean error was 28.4 m (13.6-44.3 m), which looks like a failed reconstruction.
Cause: an unconstrained SfM model is only defined up to a 7-DoF similarity (scale, rotation, translation). Its axes aren't east/north/up, its origin isn't your reference point, and its unit isn't metres. Here the scale factor turned out to be 6.74. Subtracting coordinates across the two frames measures nothing.
Fix: estimate the similarity first, then compare. With COLMAP itself:
colmap model_aligner --input_path sparse/0 --output_path sparse/aligned \
--ref_images_path gps_local.txt --ref_is_gps 0 --robust_alignment_max_error 3
# => Alignment error: 0.184395 (mean), 0.170425 (median) => Alignment succeededTraps hit on 3.7:
- With defaults it refuses to run: ERROR: You must provide a maximum alignment error > 0 (--robust_alignment defaults to 1 and --robust_alignment_max_error to 0). Pass a threshold in reference units, or --robust_alignment 0.
- --ref_is_gps defaults to 1, so a local name X Y Z file gets read as lat/lon/alt: Alignment error: 6375486.9 (mean) (about one Earth radius), Alignment failed. Use --ref_is_gps 0 for metric XYZ, or give it the raw name lat lon alt file with --ref_is_gps 1 --alignment_type enu (same 0.185 m mean here).
- A # comment header line is counted as a reference ('Using 61 reference images' for 60 photos). It's harmless but confusing. Strip it.
Or in numpy (Umeyama/Kabsch with scale) on the matched centres. That gave the same answer: scale 6.74, median residual 0.17 m (0.16 m horizontal, 0.04 m vertical). So the reconstruction was fine all along.
Caveat: all 60 photos were from one orbit at nearly constant height (GPS Z range 0.1 m), so the vertical part of the fit is weakly constrained. Include photos from several altitude rings before trusting heights. Use RelativeAltitude, or one consistent altitude field, for Z.
Verify: after model_aligner, model_converter --output_type TXT, then recompute camera centres. They should be within GPS noise (decimetres to a few metres) of the reference positions.