calibration¶
A rig's camera parameters as a document, and their refinement by bundle adjustment.
A Calibration is one estimate of a rig: a
label, each view's ViewSpec (a hand-written orbit
placement or a solve's raw parameters) and whether it is solved, which keeps it
read-only in the GUI and records what it was refined from and the fingerprint of the
stage that refined it (ADR-0036). A project keeps a set of them under
calibrations/ and its manifest names the active one (ADR-0016, ADR-0081); a run
stores the same document as its calibration attribute (ADR-0086).
refine_bundle is the solve.
Calibration ¶
Bases: Table
One estimate of a rig's parameters, as a project's calibrations/*.toml has it.
Attributes:
| Name | Type | Description |
|---|---|---|
label |
str
|
A human tag ( |
views |
dict[str, ViewSpec]
|
|
solved |
bool
|
Whether it came out of bundle adjustment; a hand-edited spec is not. |
refined_from |
int | None
|
The id of the calibration it was refined from, when solved. |
fingerprint |
str | None
|
The producing |
copied_from |
int | None
|
On the copy a run stores as its initial parameters, the id of
the project calibration the values were copied from, when they were
(ADR-0086); a calibration imported from the run records it as
|
Source code in src/deeperfly/calibration.py
of_rig
classmethod
¶
of_rig(
label: str,
rig: Rig,
*,
solved: bool = False,
refined_from: int | None = None,
fingerprint: str | None = None,
frame_hw: Mapping[str, tuple[int, int]] | None = None,
) -> Calibration
A calibration of raw views standing for rig, solved in frame_hw.
Source code in src/deeperfly/calibration.py
resolve ¶
The concrete rig; frame_hw sets an orbit view's default principal point.
calibration_files ¶
The (id, path) of each NNNN-<label>.toml in a directory, by id.
Source code in src/deeperfly/calibration.py
calibration_ids ¶
The ids of the calibrations in a calibrations/ directory, ascending.
calibration_path ¶
The file of calibration cid in a calibrations/ directory, or None.
calibration_toml ¶
The TOML text of a calibration: the head keys, then a [views.<name>] each.
A key at its default is left out, so a hand-written file stays as short.
Source code in src/deeperfly/calibration.py
parse_calibration ¶
A calibration from the TOML text of a calibrations/*.toml, strictly.
Raises:
| Type | Description |
|---|---|
ConfigError
|
If the text is not valid TOML, a key is unknown, or a view's placement is not whole. |
Source code in src/deeperfly/calibration.py
read_calibration ¶
Read a calibrations/*.toml (a run stores the same text as calibration).
Raises:
| Type | Description |
|---|---|
ConfigError
|
As |
Source code in src/deeperfly/calibration.py
refine_bundle ¶
refine_bundle(
rig: Rig,
pts2d: Float[ndarray, "V N 2"],
weights: Float[ndarray, "V N"] | None = None,
*,
fixed: Sequence[str] = ("*.intr", "*.dist"),
shared: Sequence[Sequence[str]] = (),
loss: str = "huber",
threshold_px: float = 8.0,
max_nfev: int = 200,
) -> Rig
Bundle-adjust rig to fit pts2d, holding the fixed parameters.
Each column of pts2d (V, N, 2) is one 3D track, and one seen in fewer than two
views is dropped. By default only the poses move: a ring of cameras around a
tethered fly sees 2 mm of depth and cannot tell a focal from a distance. A rig
that sees depth should free the focal and share it per physical camera (ADR-0057):
fixed without "*.intr" (keep "*.intr[2]", "*.intr[3]") and a shared group
per camera. With every pose free the fit has seven flat gauge directions, so fix
one view's rvec and tvec to hold the world frame. fixed and shared use
build_state's grammar; weights are
per observation (confidences), loss and threshold_px the robust loss.
Returns the refined rig.
Raises:
| Type | Description |
|---|---|
ValueError
|
If no track is seen in two views, or a |
Source code in src/deeperfly/calibration.py
write_calibration ¶
Write a calibration into a calibrations/ directory and return its id.
A new one takes the next free id, from 1; a given cid is overwritten in place,
the file renamed if its label changed.
Raises:
| Type | Description |
|---|---|
KeyError
|
If a given |