Skip to content

Commit daf6afa

Browse files
Add technical overview of the camera solver.
1 parent a6f07da commit daf6afa

3 files changed

Lines changed: 214 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
.. _global-optimization-heading:
2+
3+
Global Optimization
4+
===================
5+
6+
The core :ref:`camera solver <camera-solver-overview-heading>` assumes
7+
known camera intrinsics. When intrinsic parameters such as focal
8+
length are unknown or only approximate, the **Global Optimization**
9+
step wraps the core solver to search for the values that produce the
10+
best reconstruction.
11+
12+
Overview
13+
--------
14+
15+
Global optimization treats the core camera solver as a black box. It
16+
repeatedly runs the full solve pipeline with different candidate
17+
parameter values, searching for the parameters that minimize overall
18+
reprojection error across the entire sequence.
19+
20+
This is computationally expensive -- each evaluation requires a
21+
complete camera solve -- but it allows the solver to recover
22+
parameters that cannot be estimated within the incremental SfM
23+
pipeline itself.
24+
25+
Search Strategies
26+
-----------------
27+
28+
Two search strategies are available:
29+
30+
**Differential Evolution (DE)** -- A population-based evolutionary
31+
optimization algorithm. A population of candidate parameter sets
32+
evolves over multiple generations, with mutation and crossover
33+
operators exploring the search space. Supports coarse-then-refined
34+
passes: a broad initial search narrows the parameter range, followed
35+
by a finer search within the narrowed bounds. This is generally the
36+
preferred strategy for efficiency.
37+
38+
**Uniform Grid Search (UGS)** -- Exhaustive evaluation at regular
39+
intervals across the parameter range. Simpler and easier to reason
40+
about, but slower than Differential Evolution for high-dimensional or
41+
wide-range searches.
42+
43+
Parameters
44+
----------
45+
46+
Currently, the global optimization step supports searching for
47+
**focal length** (applied uniformly across the sequence).
48+
49+
*Further detail on configuration, parameter ranges, and performance
50+
characteristics will be added in future.*
51+
52+
See Also
53+
--------
54+
55+
- :ref:`camera-solver-overview-heading` -- The core camera solver
56+
pipeline that is evaluated at each optimization step.
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
.. _camera-solver-overview-heading:
2+
3+
Camera Solver Overview
4+
======================
5+
6+
The camera solver performs **incremental Structure-from-Motion (SfM)**,
7+
reconstructing camera motion and 3D point positions from 2D marker
8+
tracks in an image sequence.
9+
10+
**Input:**
11+
12+
- 2D marker tracks (per-frame screen-space positions).
13+
- Known camera intrinsics (focal length, film back size).
14+
15+
**Output:**
16+
17+
- Per-frame camera poses (rotation and translation).
18+
- 3D bundle positions (world-space coordinates for each tracked marker).
19+
20+
The solver is **deterministic** -- the same input data will always
21+
produce the same output. There is no random seeding or
22+
non-deterministic behaviour.
23+
24+
An optional :ref:`global-optimization-heading` step can wrap the
25+
solver to search for optimal global parameters (such as focal length).
26+
27+
Pipeline Overview
28+
-----------------
29+
30+
The solver runs in six phases:
31+
32+
1. Frame Analysis and Marker Selection
33+
2. Initial Two-Camera Reconstruction
34+
3. Incremental Camera Addition
35+
4. Bundle Validation and Filtering
36+
5. Final Global Bundle Adjustment
37+
6. Origin Frame Transform and Scale
38+
39+
Phase 1: Frame Analysis and Marker Selection
40+
---------------------------------------------
41+
42+
The solver analyzes all frames to select the best markers and frames
43+
for reconstruction, scoring by two criteria:
44+
45+
- **Parallax** -- how much markers move between frames. More motion
46+
provides more information for recovering 3D structure.
47+
48+
- **Uniformity** -- how evenly markers are spread across the image,
49+
measured by dividing the image into a grid and checking the
50+
distribution of points across cells. Well-spread markers give
51+
stronger geometric constraints than clustered ones.
52+
53+
The result is a selected subset of markers and the frames where
54+
those markers are visible.
55+
56+
Phase 2: Initial Two-Camera Reconstruction
57+
-------------------------------------------
58+
59+
A good starting pair is critical -- errors here propagate through
60+
the entire reconstruction.
61+
62+
The solver builds a frame graph evaluating all frame pairs by
63+
parallax and marker overlap, then selects the best pair. The
64+
relative pose between the two cameras is estimated using the
65+
**Essential Matrix** (computed via the 5-point or 8-point algorithm
66+
depending on the number of correspondences), which is decomposed
67+
into candidate rotation and translation solutions. The correct
68+
solution is chosen by triangulating points and verifying they are
69+
in front of both cameras.
70+
71+
Initial 3D points are triangulated using the **optimal angular
72+
method**, and a two-camera **bundle adjustment** refines the result.
73+
74+
Phase 3: Incremental Camera Addition
75+
--------------------------------------
76+
77+
With an initial reconstruction established, the solver adds cameras
78+
incrementally in two passes:
79+
80+
- **Pass 1 (Draft):** Adds skeleton key frames spread across the
81+
sequence, building a stable backbone.
82+
- **Pass 2 (Final):** Fills in all remaining frames.
83+
84+
For each new frame, the solver runs **PnP (Perspective-n-Point)**
85+
using the **SQPnP** algorithm to compute the camera pose from known
86+
3D points, validates the result, and refines with a single-camera
87+
bundle adjustment.
88+
89+
After each round of camera additions, a **global bundle adjustment**
90+
refines all cameras and points together. Additional markers are then
91+
triangulated and added to the reconstruction. Markers that fail
92+
geometric triangulation are placed at the **mean scene depth** as
93+
an initial estimate and refined by subsequent bundle adjustment --
94+
this ensures as many markers as possible contribute to the result.
95+
96+
Phase 4: Bundle Validation and Filtering
97+
-----------------------------------------
98+
99+
The solver validates the reconstruction by filtering out 3D bundles
100+
with high reprojection error or degenerate geometry, and checking for
101+
cameras converging to the same position, indicating a failed solve.
102+
103+
Phase 5: Final Global Bundle Adjustment
104+
----------------------------------------
105+
106+
A final bundle adjustment refines all cameras and 3D points
107+
together. Small noise is added to parameters to help escape local
108+
minima, and remaining markers are retriangulated and included.
109+
110+
Phase 6: Origin Frame Transform and Scale
111+
-------------------------------------------
112+
113+
SfM reconstructions live in an arbitrary coordinate system with no
114+
meaningful relationship to the real-world scene. The solver transforms
115+
the result to align with a user-specified **origin frame** and applies
116+
a **scene scale factor**, so the solved camera output is consistently
117+
scaled for use in MatchMove workflows.
118+
119+
Key Algorithms
120+
--------------
121+
122+
.. list-table::
123+
:header-rows: 1
124+
:widths: 30 70
125+
126+
* - Algorithm
127+
- Purpose
128+
* - Essential Matrix (5-point / 8-point)
129+
- Initial relative pose between two cameras
130+
* - SQPnP
131+
- Camera pose from 3D-2D correspondences
132+
* - Optimal Angular Triangulation
133+
- 3D point estimation from multiple views
134+
* - Depth-based Triangulation
135+
- Fallback for points that fail geometric triangulation
136+
* - Levenberg-Marquardt Bundle Adjustment
137+
- Non-linear refinement of all parameters; dense or sparse
138+
depending on problem size
139+
* - Bundle Validation
140+
- Reprojection error filtering and collapse detection
141+
142+
Bundle Adjustment
143+
-----------------
144+
145+
Bundle adjustment minimizes **reprojection error** -- the distance
146+
between where a 3D point projects into each camera and where the
147+
marker was observed. It jointly optimizes camera poses (rotation and
148+
translation) and 3D point positions using the Levenberg-Marquardt
149+
algorithm, with a dense or sparse solver selected based on problem
150+
size.
151+
152+
See Also
153+
--------
154+
155+
- :ref:`global-optimization-heading` -- Optional focal length
156+
optimization wrapping the core solver.

docs/source/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ details and features to use.
4040
.. toctree::
4141
:maxdepth: 1
4242

43+
camera_solver_overview
44+
camera_solver_global_optimization
4345
solver_concepts
4446
solver_design
4547
nodes

0 commit comments

Comments
 (0)