Calibration¶
The charucal.calibrate module contains the classes that turn raw corner detections into
homography matrices ready for runtime use.
Overview¶
from charucal import Calibrator
calibrator = Calibrator(pattern) # (1) create the calibrator
capture = calibrator.detect(frames) # (2) detect corners in one frame set
result = calibrator.calibrate(*captures) # (3) compute homographies
result.save("calibration.json") # (4) persist to disk
Loading the result later:
Reference¶
Calibrator
¶
A class for calibrating multi-camera systems using ChArUco boards.
Initialize the calibrator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
CalibrationPattern
|
The ChArUco pattern to use for calibration. |
required |
ref_idx
|
int | None
|
The index of the reference camera. When |
None
|
Methods:
| Name | Description |
|---|---|
calibrate |
Calibrate the multi-camera system. |
detect |
Detect the calibration pattern in the provided images without computing homographies. |
Source code in src/charucal/calibrate.py
calibrate
¶
Calibrate the multi-camera system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
captures
|
CalibrationCapture
|
The captures to use for calibration. |
()
|
Returns:
| Type | Description |
|---|---|
CalibrationResult
|
The result of the calibration. |
Source code in src/charucal/calibrate.py
detect
¶
Detect the calibration pattern in the provided images without computing homographies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
Sequence[NDArray[uint8]]
|
A sequence of images captured by the cameras. The order of the images should correspond to the order of the cameras. |
required |
Returns:
| Type | Description |
|---|---|
CalibrationCapture
|
The detected calibration grids and source shapes. |
Source code in src/charucal/calibrate.py
CalibrationCapture
dataclass
¶
The result of detecting the calibration pattern in a multi-camera system.
Attributes:
| Name | Type | Description |
|---|---|---|
grids |
list[CalibrationGrid]
|
A list of detected calibration grids for each camera. |
source_shapes |
Sequence[tuple[int, int]]
|
The source frame dimensions |
is_complete |
bool
|
Whether every camera detected at least one corner. |
num_cameras |
int
|
The number of cameras in the multi-camera system. |
CalibrationResult
dataclass
¶
CalibrationResult(
stitch_matrices: NDArray[float64],
topdown_matrix: NDArray[float64],
source_shapes: Sequence[tuple[int, int]],
ref_idx: int,
)
The result of calibrating a multi-camera system.
Methods:
| Name | Description |
|---|---|
save |
Save the calibration result to a |
load |
Load the calibration result from a |
Attributes:
| Name | Type | Description |
|---|---|---|
stitch_matrices |
NDArray[float64]
|
A |
topdown_matrix |
NDArray[float64]
|
A |
source_shapes |
Sequence[tuple[int, int]]
|
The source frame dimensions |
ref_idx |
int
|
The index of the reference camera. |
num_cameras |
int
|
The number of cameras in the multi-camera system. |
stitch_matrices
instance-attribute
¶
A (N, 3, 3) array of homographies mapping each camera's pixel space to the reference camera's pixel space.
topdown_matrix
instance-attribute
¶
A (3, 3) homography mapping the reference camera's pixel space to the physical world coordinates in meters,
with the origin at the ChArUco's board detected position.
source_shapes
instance-attribute
¶
The source frame dimensions (width, height) for each camera.
save
¶
Save the calibration result to a .json file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
The path to save the calibration result to. |
required |
Source code in src/charucal/calibrate.py
load
classmethod
¶
Load the calibration result from a .json file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
The path to load the calibration result from. |
required |
Returns:
| Type | Description |
|---|---|
CalibrationResult
|
The calibration result. |