CalibrationGrid¶
CalibrationGrid is the internal data structure that holds detected ChArUco corners for
a single camera image. It is returned by CalibrationPattern.detect() and consumed by
Calibrator.
Structure¶
A grid is a NumPy array of shape (H-1, W-1, 2), where H and W are the number of
squares on the board. Each cell stores the (x, y) pixel coordinate of the corresponding
inner corner, or NaN if that corner was not detected.
Reference¶
CalibrationGrid
¶
Represents the detected corners of a ChArUco board as a grid.
Initializes the grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid
|
NDArray[float32]
|
The detected ChArUco corners as a (h, w, 2) array. |
required |
Methods:
| Name | Description |
|---|---|
find_homography |
Finds the homography mapping this grid to another grid. |
flatten |
Flattens the grid into a (n, 2) array of corner positions. |
is_empty |
Checks if the grid is empty (no corners detected). |
merge |
Merges another grid into this one, filling in any missing corners. |
empty |
Creates an empty grid of the given shape. |
from_corners |
Creates a grid from detected ChArUco corners. |
from_shape |
Creates a grid of ideal corner positions for a ChArUco board. |
__repr__ |
Returns a string representation of the grid. |
__str__ |
Returns a string representation of the grid. |
Attributes:
| Name | Type | Description |
|---|---|---|
grid |
NDArray[float32]
|
The detected ChArUco corners. Each cell contains the (x, y) image coordinates of the corner, |
visible_mask |
NDArray[bool_]
|
A boolean mask of the visible corners. |
visible_corners |
tuple[NDArray[float32], NDArray[intp]]
|
The visible corners and their ids. |
Source code in src/charucal/grid.py
grid
instance-attribute
¶
The detected ChArUco corners. Each cell contains the (x, y) image coordinates of the corner, or NaN if not detected.
visible_corners
property
¶
The visible corners and their ids.
find_homography
¶
Finds the homography mapping this grid to another grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
CalibrationGrid
|
The grid to find the homography to. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
The homography mapping this grid to the other grid. |
Source code in src/charucal/grid.py
flatten
¶
is_empty
¶
Checks if the grid is empty (no corners detected).
Returns:
| Type | Description |
|---|---|
bool
|
Whether the grid is empty. |
merge
¶
Merges another grid into this one, filling in any missing corners.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
CalibrationGrid
|
The grid to merge into this one. |
required |
Returns:
| Type | Description |
|---|---|
CalibrationGrid
|
This grid with the other grid merged in. |
Source code in src/charucal/grid.py
empty
classmethod
¶
Creates an empty grid of the given shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
tuple[int, int]
|
The shape of the ChArUco board (w, h). |
required |
Returns:
| Type | Description |
|---|---|
CalibrationGrid
|
An empty grid. |
Source code in src/charucal/grid.py
from_corners
classmethod
¶
from_corners(
shape: tuple[int, int],
corners: NDArray[float32],
ids: NDArray[intp],
) -> CalibrationGrid
Creates a grid from detected ChArUco corners.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
tuple[int, int]
|
The shape of the ChArUco board (w, h). |
required |
corners
|
NDArray[float32]
|
The image coordinates of the detected corners. |
required |
ids
|
NDArray[intp]
|
The ids of the detected corners. |
required |
Returns:
| Type | Description |
|---|---|
CalibrationGrid
|
A grid of detected corner positions. |
Source code in src/charucal/grid.py
from_shape
classmethod
¶
Creates a grid of ideal corner positions for a ChArUco board.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
tuple[int, int]
|
The shape of the ChArUco board (w, h). |
required |
length
|
float
|
The square side length. |
required |
Returns:
| Type | Description |
|---|---|
CalibrationGrid
|
A grid of ideal corner positions. |