Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions docs/benchmarks/chen2020_graph_sfm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Chen et al. GraphSfM baseline

This baseline reimplements the image clustering, maximum-spanning-tree (MaxST)
subgraph expansion, and minimum-spanning-tree (MinST) + minimum-height-tree
(MHT) sub-model merging steps from
[Chen et al., arXiv:1912.10659, Sections 3.1–3.2](https://arxiv.org/pdf/1912.10659)
(Algorithms 1 and 2). It accepts a verified COLMAP database, matching the input
contract of the Zhu 2018 baseline so experiments can share image pairs,
keypoints, matches, and camera metadata. Pair filtering applies to a frozen
snapshot.

1. Recursively partition the inlier-weighted view graph with normalized cuts
under the base size bound `S_max` (`--max-cameras`). Build the cluster graph
weighted by lost image edges, compute its MaxST via Kruskal's algorithm, and
expand clusters along MaxST edges (then remaining lost edges) until the
completeness ratio `eta(i) >= C` (`--completeness-ratio`) or `--max-overlap`
is reached.
2. Reconstruct each expanded cluster independently with PyCOLMAP incremental
SfM.
3. Estimate pairwise `Sim(3)` transforms between overlapping clusters using
median pairwise baseline scale and RANSAC over camera-pose hypotheses
refitted with chordal SO(3) orientation averaging and optimal scale/translation.
Weight each cluster-graph edge by symmetric Mean Square Distance (`msd`,
Eqs. 10–11) over shared 3D track points (falling back to camera centers).
4. Compute the Kruskal MinST of the largest cluster-graph component, peel leaf
nodes layer-by-layer to select the MHT anchor cluster, and compose `Sim(3)`
transforms along tree paths into the anchor frame.
5. Carry local camera intrinsics into PyCOLMAP triangulation and final sparse
BA, and score poses with GTSfM's evaluator (`sim3_from_Pose3_maps` and
`compute_ba_pose_metrics`). Reference poses enter only the evaluator.

The implementation runs on a single host using PyCOLMAP for local incremental
mapping, global triangulation, and final sparse BA, whereas the paper distributes
local COLMAP jobs across multiple servers. Pairwise `Sim(3)` refitting uses both
camera orientations and centers (avoiding roll ambiguity when overlapping camera
centers are nearly collinear) rather than point-only Euclidean alignment.

## Reproduce

Run from the repository root in the pinned GTSfM environment (`uv run`). Each
run writes a verified database snapshot (`frontend.db`), local reconstructions,
final COLMAP geometry, and `metrics.json` to a new output directory. The
reported `frontend_sha256` identifies the filtered `frontend.db` snapshot.

```sh
uv run python -m scripts.run_graph_sfm \
--database tests/data/set1_lund_door/colmap.db \
--images tests/data/set1_lund_door/images \
--olsson-reference tests/data/set1_lund_door \
--max-cameras 6 --min-pair-inliers 3800 --output .context/door-graphsfm
```

On Lund Door, `--min-pair-inliers 3800` produces 25 verified pairs, three base
clusters (`5, 3, 4` cameras), a 2-edge MaxST (`0–1–2`), and expanded clusters of
`7, 6, 5` cameras with 3 common cameras on each edge. The MHT selects cluster 1
as the anchor.

The Reichstag fixture uses a fresh CPU SIFT database with exhaustive matching,
matching the Zhu 2018 setup:

```sh
mkdir -p .context
uv run python - <<'PY'
import pycolmap

database = ".context/reichstag-sift.db"
images = "tests/data/imb_reichstag/images"
pycolmap.set_random_seed(0)
pycolmap.extract_features(
database,
images,
sift_options=pycolmap.SiftExtractionOptions(num_threads=2, max_num_features=4096),
device=pycolmap.Device.cpu,
)
pycolmap.match_exhaustive(
database,
sift_options=pycolmap.SiftMatchingOptions(num_threads=2),
device=pycolmap.Device.cpu,
)
PY
uv run python -m scripts.run_graph_sfm \
--database .context/reichstag-sift.db \
--images tests/data/imb_reichstag/images \
--yfcc-imb-reference tests/data/imb_reichstag \
--max-cameras 6 --completeness-ratio 0.4 --max-overlap 4 \
--output .context/reichstag-graphsfm-ov4
```

## Observed results

All runs below were executed on the same frozen `frontend.db` per scene (single
Mac, CPU, `num_threads=2`). Single-model PyCOLMAP incremental SfM on the same
frozen databases is included for reference.

| Fixture / Method | Final registered / input | Final points | Mean reproj. (px) | Pose AUC at 5° after merging | Pose AUC at 5° after final BA |
| --- | ---: | ---: | ---: | ---: | ---: |
| Lund Door — GraphSfM (free intrinsics) | 12 / 12 | 11,125 | 0.395 | 0.9100 | 0.9070 |
| Lund Door — GraphSfM (`--fix-final-intrinsics`) | 12 / 12 | 11,125 | 0.395 | 0.9100 | 0.9131 |
| Lund Door — Single-model PyCOLMAP (same DB) | 12 / 12 | 11,028 | 0.341 | — | 0.9064 |
| Reichstag — GraphSfM (`C=0.4`, `O_max=4`, free) | 10 / 10 | 1,887 | 0.510 | 0.2932 | 0.1985 |
| Reichstag — GraphSfM (`C=0.4`, `O_max=4`, fixed) | 10 / 10 | 1,887 | 0.510 | 0.2932 | 0.1856 |
| Reichstag — GraphSfM (`C=0.5`, unbounded overlap) | 10 / 10 | 2,144 | 0.407 | 0.5254 | 0.5245 |
| Reichstag — Single-model PyCOLMAP (same DB) | 10 / 10 | 2,199 | 0.400 | — | 0.5254 |
| Dubrovnik6K (120-img Old Town) — GraphSfM (`S_max=50`, `O_max=20`) | 114 / 120 | 21,656 | 1.085 | 0.4489 | 0.5216 |
| Dubrovnik6K (120-img Old Town) — Single-model PyCOLMAP (`multiple_models=True`) | 115 / 120 | 21,577 | 0.773 | — | 0.5550 |
| Dubrovnik6K (120-img Old Town) — Single-model PyCOLMAP (`multiple_models=False`) | 5 / 120 | 0 | 0.000 | — | 0.0000 |

Notes:

- On Lund Door, GraphSfM exercises a 3-cluster chain (`0–1–2`, `msd = 0.0452` and
`0.0763`), selects the central cluster `1` via MHT, and matches or slightly
exceeds both single-model PyCOLMAP (`0.9064`) and the Zhu 2018 baseline
(`0.9068`) on the same 25-pair graph.
- On Reichstag (10 uncalibrated internet photos), unbounded expansion at
`C=0.5` expands cluster 0 to all 10 cameras (making it equivalent to
single-model PyCOLMAP). Bounding overlap (`--max-overlap 4`) forces a genuine
2-cluster merge (`9` and `5` cameras, `4` common cameras, `msd = 1.5437`),
where local self-calibration without the 10th camera lowers individual local
cluster quality (`local-0` alone achieves `AUC@5° = 0.2689`, `local-1`
`0.2378`). Re-running on the same frozen `frontend.db` reproduced cluster
membership, `msd`, point count, and pose AUC bit-for-bit.
- On Dubrovnik6K (120 spatially contiguous Old Town images within 6.6 m of
`[32.9, -7.6, 209.3]` from `Dubrovnik6K_images.tar`, 3,835 verified SIFT
pairs, evaluated against `bundle.orig.out` + `list.orig.txt` via
`--bundler-reference` / `--bundler-list`), GraphSfM (`--max-cameras 50
--completeness-ratio 0.5 --max-overlap 20`) forms a 4-cluster graph with a
cycle (`0–2–3–0` + `1–3`). Kruskal MinST drops the higher-MSD cycle edge
`(0, 3)` (`msd=12.53`) in favor of `0–2–3` (`msd=5.06, 3.56`), MHT peels the
4-node tree and breaks the 2-node center tie (`{2, 3}`) by size (`60 > 30`) to
select cluster `3` as anchor, and total runtime is 69.3 s sequentially vs
94.4 s for single-model PyCOLMAP (`multiple_models=True`). With smaller
clusters (`--max-cameras 30`), one local cluster diverged catastrophically
during local COLMAP, underscoring the sensitivity of internet-photo local
submodels to cluster size.
Loading
Loading