bundle
bundle
#
bundle_adjust — cameras and points refined together until the reprojections agree.
- Parameters. Each camera is a Rodrigues rotation and a translation (world-to-camera), plus a focal length and principal point when intrinsics are refined; each point is its three coordinates.
- Residuals. Every observation contributes its reprojection error in
pixels, under a pseudo-Huber loss so a wrong match cannot drag the rest
(the smooth loss converges where Huber's knee stalls the solver). With a
position sigma, every camera also contributes
(centre − prior) / sigma, its prior being where it stood on entry; without one, the first camera is held fixed so the model cannot drift as a whole. - Solve. SciPy's trust-region least squares, told which residual depends
on which parameter, so the Jacobian is sparse.
adjustis that solver over plain arrays, which the incremental reconstruction reuses.
ROBUST_SCALE_PX = 2.0
module-attribute
#
Residuals beyond this many pixels count roughly linearly, not quadratically.
adjust(cameras, points, camera, point, pixels, fixed, priors, sigma, refine_intrinsics)
#
The cameras and points that best reproject pixels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cameras
|
Cameras
|
The cameras to start from. |
required |
points
|
ndarray
|
The N×3 points to start from. |
required |
camera
|
ndarray
|
The camera of each observation. |
required |
point
|
ndarray
|
The point of each observation. |
required |
pixels
|
ndarray
|
The M×2 pixel of each observation. |
required |
fixed
|
ndarray
|
Per camera, whether its pose is held; intrinsics being refined move regardless. |
required |
priors
|
ndarray | None
|
C×3 centres the cameras are drawn to, or |
required |
sigma
|
float | None
|
The metres one prior residual unit spans; required with |
required |
refine_intrinsics
|
bool
|
Whether focal lengths and principal points move. |
required |
Returns:
| Type | Description |
|---|---|
Cameras
|
|
ndarray
|
numbers a log line reports — reprojection before and after in |
dict[str, float | int]
|
pixels, the mean and largest camera shift in metres, iterations. |
Source code in capturegraph-recipes/capturegraph_recipes/sfm/reconstruction/bundle.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
bundle_adjust(frames, model, position_sigma_meters=None, refine_intrinsics=False)
#
model with its cameras and points moved to minimise reprojection error.
The frames supply the images whose keypoints the observations index;
their poses play no part — the model's cameras are the starting point,
and the priors when a sigma is given.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frames
|
Array[PosedImage]
|
The posed images the model was built from. |
required |
model
|
Reconstruction
|
The reconstruction to refine. |
required |
position_sigma_meters
|
float | None
|
How far a camera centre may plausibly move
from where the model has it; |
None
|
refine_intrinsics
|
bool
|
Whether each camera's focal length and principal point are solved for too. |
False
|