alexmkwizu's picture
Document colmap_golden_bundle in llm.txt
511152c verified
Raw
History Blame Contribute Delete
6.99 kB
# COLMAP Testing Dataset — usage & data guide (for LLMs/agents and humans)
Purpose: ready-to-run multi-view image scenes for testing/benchmarking the
COLMAP SfM/MVS pipeline. 7 scenes, 415 images, ~3.2 GB, in two families with
two different on-disk layouts. Everything is already in COLMAP's expected
structure — no preprocessing needed.
## Scenes
ETH3D high-res DSLR (images at `<scene>/images/dslr_images/`, 6048x4032 JPG,
ground-truth in `<scene>/dslr_calibration_jpg/`):
- courtyard (38 images)
- electro (45 images)
- kicker (31 images)
- relief (31 images)
- terrains (42 images)
COLMAP example scenes (images at `<scene>/images/`, reference model in
`<scene>/sparse/`, prebuilt `<scene>/database.db`):
- gerrard-hall (100 images, database.db 158 MB)
- south-building (128 images, database.db 211 MB)
## On-disk layout
ETH3D:
<scene>/images/dslr_images/*.JPG # inputs (24 MP)
<scene>/dslr_calibration_jpg/cameras.txt # GT intrinsics (THIN_PRISM_FISHEYE)
<scene>/dslr_calibration_jpg/images.txt # GT poses (2 lines per image)
<scene>/dslr_calibration_jpg/points3D.txt # GT sparse points
COLMAP examples:
<scene>/images/*.JPG # inputs
<scene>/sparse/{cameras.txt,images.txt,points3D.txt} # reference sparse model
<scene>/database.db # prebuilt SQLite DB: features + matches already done
IMPORTANT path difference: ETH3D images live under `images/dslr_images`, COLMAP
examples under `images`. Pass the correct `--image_path` accordingly.
## COLMAP model file formats (what cameras/images/points3D mean)
These are COLMAP's standard sparse-model text files (same schema everywhere).
cameras.txt — one line per camera:
CAMERA_ID MODEL WIDTH HEIGHT PARAMS...
ETH3D uses MODEL=THIN_PRISM_FISHEYE with 12 params
(fx fy cx cy k1 k2 p1 p2 k3 k4 sx1 sy1). COLMAP example scenes use simpler
models (e.g. SIMPLE_RADIAL / PINHOLE) — read the file, don't assume.
images.txt — TWO lines per image (this trips up naive parsers):
line 1: IMAGE_ID QW QX QY QZ TX TY TZ CAMERA_ID NAME
(quaternion + translation = world-to-camera, i.e. cam_from_world)
line 2: X Y POINT3D_ID X Y POINT3D_ID ... (2D keypoints; -1 = no 3D match)
So image count = (non-comment, non-blank lines) / 2.
points3D.txt — one line per 3D point:
POINT3D_ID X Y Z R G B ERROR (IMAGE_ID POINT2D_IDX)... (the track)
Binary equivalents (cameras.bin/images.bin/points3D.bin) are interchangeable;
convert with `colmap model_converter --output_type {BIN,TXT}`.
## How to run COLMAP on a scene
Set the image path per family, then:
SCENE=south-building; IMG=$SCENE/images # COLMAP examples
SCENE=relief; IMG=$SCENE/images/dslr_images # ETH3D
Sparse (from scratch):
colmap feature_extractor --image_path "$IMG" --database_path db.db
colmap exhaustive_matcher --database_path db.db # small/medium scenes
colmap mapper --image_path "$IMG" --database_path db.db --output_path sparse
colmap model_analyzer --path sparse/0
Reuse the prebuilt database (COLMAP example scenes only — skips extract+match):
colmap mapper --image_path south-building/images \
--database_path south-building/database.db --output_path sparse
Dense MVS (needs a Metal or CUDA build; after sparse):
colmap image_undistorter --image_path "$IMG" --input_path sparse/0 --output_path dense
colmap patch_match_stereo --workspace_path dense
colmap stereo_fusion --workspace_path dense --output_path dense/fused.ply
## Loading / evaluating against ground truth
- Load a model in Python: `import pycolmap; rec = pycolmap.Reconstruction("relief/dslr_calibration_jpg")`
then `rec.cameras`, `rec.images` (each has `.cam_from_world`), `rec.points3D`.
- The ETH3D `dslr_calibration_jpg` and the COLMAP `sparse` folders ARE valid
COLMAP models — open them directly to get GT/reference poses and points.
- Typical SfM eval: run your pipeline, align your model to the GT model
(`colmap model_aligner` / pycolmap), then compare camera centers and rotations.
## Choosing a scene
- Fastest smoke test: relief or kicker (31 imgs each).
- Larger / stress: gerrard-hall (100) or south-building (128).
- Skip extraction+matching: the two COLMAP scenes ship database.db.
- Distortion / high-res robustness: any ETH3D scene (24 MP, fisheye).
- Pose-accuracy evaluation: any scene (all ship a GT/reference model).
## Golden MVS reference (colmap_golden_bundle/)
Also in this repo: `colmap_golden_bundle/` = the CUDA `patch_match_stereo`
golden output for the `south-building` scene (upstream COLMAP 4.0.4 + CUDA on an
NVIDIA T4). Purpose: a "did I port the SAME algorithm faithfully" reference to
diff a Metal/other MVS port against — NOT ground-truth accuracy (CUDA output is
itself an approximation; for accuracy use ETH3D/DTU real GT).
Layout:
colmap_golden_bundle/
note.md # full provenance + reader (read this)
colmap_cuda_golden_data.ipynb # idempotent notebook that produced it
golden_mvs/dense/fused.ply # 3,609,743 points (93 MB)
golden_mvs/dense/stereo/depth_maps/*.geometric.bin # 128 depth maps (reference)
golden_mvs/dense/stereo/normal_maps/*.geometric.bin # 128 normal maps
logs/ # undistort / patch_match / fusion logs
Map format: COLMAP dense binary — ASCII header "width&height&channels&" then
little-endian float32 in Fortran (column-major) order; 0 = invalid (ignore
zeros). Depth = HxW, normals = HxWx3. Reader:
import numpy as np
def read_colmap_array(path):
with open(path, "rb") as fid:
hdr, amp = b"", 0
while amp < 3:
ch = fid.read(1); hdr += ch
if ch == b"&": amp += 1
w, h, c = (int(x) for x in hdr.decode().split("&")[:3])
data = np.fromfile(fid, np.float32)
return np.transpose(data.reshape((w, h, c), order="F"), (1, 0, 2)).squeeze()
Validate a port: run `colmap patch_match_stereo` on south-building (geometric
consistency on, undistort cap 2000 px to match), then compare your
*.geometric.bin against these on overlapping valid (non-zero) pixels within
tolerance. See colmap_golden_bundle/note.md for exact pipeline + per-stage perf.
## Caveats
- The ETH3D laser-scan ground-truth surface/mesh is NOT included — only the
GT camera calibration and GT sparse points. This is for SfM/pose and MVS
smoke testing, not full MVS-accuracy benchmarking against the scan.
- ETH3D images are 24 MP: extraction/MVS are memory-heavy. Downscale with
`--SiftExtraction.max_image_size 3200` (or similar) and
`--PatchMatchStereo.max_image_size` to stay within RAM.
- THIN_PRISM_FISHEYE intrinsics must be respected; don't force a pinhole model
on ETH3D inputs if you want the GT calibration to apply.
- These scenes are redistributed for testing; cite/respect the original
sources (ETH3D: eth3d.net, CVPR 2017; COLMAP examples: colmap.github.io,
CVPR 2016). See README.md.