|
| 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. |
0 commit comments