CalibrationPattern¶
CalibrationPattern describes the physical ChArUco board you printed and uses it to detect
corners in images. Create one instance per board design and share it across your calibration
and detection code.
Example¶
import cv2
from charucal import CalibrationPattern
pattern = CalibrationPattern(
width=10,
height=8,
square_length=0.115, # meters — measure your printed board
marker_length=0.086, # meters
aruco_dict=cv2.aruco.DICT_4X4_100,
)
# Detect corners in a single image
grid = pattern.detect(image) # returns a CalibrationGrid
Choosing the right ArUco dictionary¶
The dictionary must match the one used when you generated the board.
| Dictionary | Markers | Recommended for |
|---|---|---|
DICT_4X4_50 |
50 | Small boards, few cameras |
DICT_4X4_100 |
100 | General use (default) |
DICT_5X5_100 |
100 | Larger boards, more robust detection |
DICT_6X6_250 |
250 | Very large boards |
Pass the constant directly (cv2.aruco.DICT_4X4_100) or its integer value. The CLI also
accepts the short string form (4X4_100).
Reference¶
CalibrationPattern
¶
CalibrationPattern(
width: int,
height: int,
square_length: float,
marker_length: float,
aruco_dict: int,
)
Represents a calibration pattern.
Initialize the calibration pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
The width of the calibration pattern. |
required |
height
|
int
|
The height of the calibration pattern. |
required |
square_length
|
float
|
The length of the squares on the calibration pattern. |
required |
marker_length
|
float
|
The length of the markers on the calibration pattern. |
required |
aruco_dict
|
int
|
The dictionary for the calibration pattern. |
required |
Methods:
| Name | Description |
|---|---|
detect |
Detect the ChArUco board in an image. |
get_shape |
Get the shape of the ChArUco board. |
to_grid |
Get the grid of the ChArUco board. |
Attributes:
| Name | Type | Description |
|---|---|---|
width |
int
|
The width of the calibration pattern. |
height |
int
|
The height of the calibration pattern. |
board |
CharucoBoard
|
The calibration board. |
detector |
CharucoDetector
|
The calibration pattern detector. |
Source code in src/charucal/pattern.py
board
instance-attribute
¶
The calibration board.
detector
instance-attribute
¶
The calibration pattern detector.
detect
¶
Detect the ChArUco board in an image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray[uint8]
|
The image to detect the ChArUco board in. |
required |
Returns:
| Type | Description |
|---|---|
CalibrationGrid
|
The corners and ids of the detected ChArUco board. |
Source code in src/charucal/pattern.py
get_shape
¶
to_grid
¶
Get the grid of the ChArUco board.
Returns:
| Type | Description |
|---|---|
CalibrationGrid
|
The grid of the ChArUco board. |