rig¶
The rig: an ordered set of views, and what each one is.
A View is a virtual camera: extrinsics, intrinsics, distortion
and whether it is mirrored, with pixels in the raw frame of the video it reads and no
frame size (ADR-0056). A Rig orders them, the V axis of every
array a run writes. How a view is written, in a run config's [calibration.views] or
a calibration file, is a ViewSpec: an orbit placement or
the raw parameters a solve works in, resolved against the frame size of its video
(ADR-0060).
ViewSpec
module-attribute
¶
OrbitView ¶
Bases: _Placement
A view on a ring around look_at: the human way to write a starting guess.
Placed as resolve_extrinsics says, with one
guessed focal in pixels (fx == fy) and a principal point defaulting to the
center of the frame it reads.
Attributes:
| Name | Type | Description |
|---|---|---|
distance |
float
|
Distance from |
focal |
float
|
Focal length in pixels, for both |
azimuth_deg |
float
|
Orbit rotation in the world xy-plane, in degrees. |
elevation_deg |
float
|
Orbit lift toward |
roll_deg |
float
|
Rotation about the optical axis, in degrees. |
look_at |
tuple[float, float, float]
|
The world point the view aims at. |
cx |
float | None
|
Principal-point x in pixels; omitted, |
cy |
float | None
|
Principal-point y in pixels; omitted, |
Source code in src/deeperfly/rig.py
resolve ¶
This placement as a View, frame_hw its video's frame.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the principal point defaults with no frame size given, or the view looks straight along the world up axis. |
Source code in src/deeperfly/rig.py
RawView ¶
Bases: _Placement
A view by the parameters a solve works in: what a solved rig is stored as.
Attributes:
| Name | Type | Description |
|---|---|---|
rvec |
tuple[float, float, float]
|
Axis-angle rotation vector, world to camera. |
tvec |
tuple[float, float, float]
|
Translation, world to camera. |
intr |
tuple[float, float, float] | tuple[float, float, float, float]
|
Packed intrinsics, |
image_size |
tuple[int, int] | None
|
The |
Source code in src/deeperfly/rig.py
of
classmethod
¶
The spec that resolves back to view (trailing zero distortion dropped).
Source code in src/deeperfly/rig.py
resolve ¶
This placement as a View, frame_hw its video's frame.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the view was solved in a frame of another size. |
Source code in src/deeperfly/rig.py
Rig ¶
An ordered collection of named View objects.
The order is the V axis of every stacked array, positional: observations paired
with a rig must follow it. How many videos the rig reads is a separate number.
Source code in src/deeperfly/rig.py
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 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
dists
property
¶
Per-view distortion, zero-padded to the rig-wide max length.
mirrored
property
¶
Per-view improper-pose flags of shape (V,), in order.
__init__ ¶
__repr__ ¶
One line: how many views, and the first few names in order.
Source code in src/deeperfly/rig.py
from_arrays
classmethod
¶
from_arrays(
names: list[str],
rvecs: Float[ndarray, "V 3"],
tvecs: Float[ndarray, "V 3"],
intrs: Float[ndarray, "V P"],
dists: Float[ndarray, "V K"]
| Sequence[Sequence[float]],
mirrored: Bool[ndarray, V]
| Sequence[bool]
| None = None,
) -> Rig
Build a rig from stacked per-view arrays (e.g. BA output).
dists may be one sequence per view of its own length. mirrored defaults to
none; a caller carrying a rig through a solve passes its own back, since
bundle adjustment never touches it.
Raises:
| Type | Description |
|---|---|
ValueError
|
If an array's leading length disagrees with |
Source code in src/deeperfly/rig.py
from_specs
classmethod
¶
from_specs(
specs: Mapping[str, ViewSpec],
frame_hw: Mapping[str, tuple[int, int]] | None = None,
) -> Rig
Resolve a name -> ViewSpec mapping to a rig, in mapping order.
frame_hw is each view's (height, width), which an orbit view's principal
point defaults to the center of; a raw view, or an orbit view with cx and
cy, needs none.
Raises:
| Type | Description |
|---|---|
ValueError
|
If an orbit view's principal point defaults with no frame size given, naming the view. |
Source code in src/deeperfly/rig.py
project ¶
Project (*pts, 3) world points through every view: (V, *pts, 2).
Source code in src/deeperfly/rig.py
specs ¶
Each view as a RawView, the form a solved rig is stored in.
frame_hw is each view's (height, width), recorded as the frame it was
solved in so a video of another size is refused where it resolves (ADR-0079).
Source code in src/deeperfly/rig.py
View
dataclass
¶
One virtual camera: extrinsics, intrinsics, distortion, and its handedness.
Every pixel coordinate is in the raw, whole, full-resolution frame of the video the view reads, so a crop is undone before its coordinates reach a view. A view has no name of its own; the rig that holds it keys it.
Attributes:
| Name | Type | Description |
|---|---|---|
rvec |
Float[ndarray, 3]
|
Axis-angle rotation vector of shape |
tvec |
Float[ndarray, 3]
|
Translation vector of shape |
intr |
Float[ndarray, P]
|
Packed intrinsics, |
dist |
Float[ndarray, K]
|
OpenCV-ordered distortion coefficients (may be empty). |
mirrored |
bool
|
Whether the view sees the world reflected, through a prism: its pose is improper (ADR-0053) and nothing flips the pixels. |
Source code in src/deeperfly/rig.py
position
cached
property
¶
The view's center in world coordinates, -R.T @ tvec.
rmat
cached
property
¶
The effective world-to-camera rotation (rows are the camera axes).
R(rvec), or the improper diag(-1, 1, 1) @ R(rvec) for a mirrored view.
backproject_ray ¶
The world-frame viewing ray (origin, direction) of an image pixel.
The inverse of project, origin the camera
center (backproject_ray_one).
Source code in src/deeperfly/rig.py
project ¶
Project world points of shape (*pts, 3) to this image, (*pts, 2).
Source code in src/deeperfly/rig.py
resolve_extrinsics ¶
resolve_extrinsics(
distance: float,
*,
look_at: Sequence[float] = (0.0, 0.0, 0.0),
azimuth_deg: float = 0.0,
elevation_deg: float = 0.0,
roll_deg: float = 0.0,
) -> tuple[Float[np.ndarray, 3], Float[np.ndarray, 3]]
Resolve an orbit placement to (rvec, tvec).
The camera sits at look_at + distance * dir(azimuth_deg, elevation_deg) and looks
back at look_at with world +z up, then turns by roll_deg about its optical
axis; angles in degrees.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/deeperfly/rig.py
spec_union ¶
The orbit | raw union a table is parsed as, chosen by the keys present.
For ViewSpec, and for any subclass pair that adds keys.