Interactive camera calibration tool using ChArUco boards. Provides real-time detection feedback, frame scoring, coverage tracking, corner heatmaps, and auto-capture — so you can get a high-quality calibration with minimal effort.
Works with any USB webcam, video file, or folder of images via OpenCV. Optionally subscribes to a ROS 2 image topic for robotic workflows.
- Live ChArUco detection with corner and marker overlay
- Frame scoring based on corner count, hull spread, new coverage, and sharpness
- Coverage tracking — grid, quadrant, scale, and view diversity
- Quality meter — single 0–100% bar combining all coverage dimensions
- Corner heatmap — Gaussian-splat overlay to visualize observation density
- Auto-capture — hands-free data collection with configurable cooldown
- Auto-recalibration — RMS updates as you collect more frames
- YAML export — ROS
camera_info_managercompatible format - ROS 2 integration — standalone
--ros-topicflag or dedicated ROS 2 package
git clone https://github.com/yobahcorp/charuco_calibrator.git
cd charuco_calibrator
pip install -e .For Ubuntu system dependencies, see INSTALL_UBUNTU.md.
# Webcam
charuco-calibrate --camera 0
# Video file
charuco-calibrate --video recording.mp4
# Folder of images (sorted alphabetically)
charuco-calibrate --image-folder /path/to/frames/
# ROS 2 topic (requires rclpy + cv_bridge)
charuco-calibrate --ros-topic /camera/image_raw| Key | Action |
|---|---|
SPACE |
Capture current frame |
A |
Toggle auto-capture |
C |
Run calibration (needs >= 4 frames) |
S |
Save calibration YAML + observations |
R |
Reset all data |
H |
Toggle heatmap overlay |
Q / ESC |
Quit |
All parameters can be set via a YAML config file and/or CLI flags. CLI flags override the config file.
charuco-calibrate --config my_config.yaml --camera 0 --output-dir results/| Flag | Description |
|---|---|
--config <path> |
Path to YAML config file |
--camera <id> |
Camera device ID (integer) |
--video <path> |
Path to a video file |
--image-folder <path> |
Path to a folder of images |
--ros-topic <topic> |
ROS 2 image topic name |
--output-dir <dir> |
Output directory for calibration files |
--camera-name <name> |
Camera name written into the YAML |
See config/default_config.yaml for the full reference. Key sections:
| Section | Parameters |
|---|---|
| board | squares_x, squares_y, square_length, marker_length, aruco_dict |
| thresholds | min_corners, min_blur_var, min_score, capture_cooldown_ms |
| coverage | grid_cols, grid_rows, scale_bins |
| source | camera_id, video_path, image_folder, ros_topic, width, height |
| output | output_dir, camera_name, save_observations |
- Print a ChArUco board matching your config (
squares_x,squares_y,aruco_dict). A reference image is included atcharuco_board.png. - Mount it on something rigid and flat (foam board, clipboard).
- Measure the printed square and marker sizes with a ruler and set
square_lengthandmarker_lengthto the actual values in metres.
Important: squares_x is the number of squares horizontally (columns) and squares_y is vertically (rows) as seen by the camera. marker_length must be less than square_length.
DICT_4X4_50, DICT_4X4_100, DICT_4X4_250, DICT_4X4_1000,
DICT_5X5_50, DICT_5X5_100, DICT_5X5_250, DICT_5X5_1000,
DICT_6X6_50, DICT_6X6_100, DICT_6X6_250, DICT_6X6_1000,
DICT_7X7_50, DICT_7X7_100, DICT_7X7_250, DICT_7X7_1000
Use the smallest dictionary that covers your marker count. For a 9x7 board (31 markers), DICT_4X4_50 works well.
- Fill the coverage grid — move the board to cover all cells
- Vary distance — show the board close-up and far away
- Vary angle — tilt the board in different directions
- Stay sharp — hold still; blurry frames are rejected automatically
- Watch the quality meter — aim for 80%+ before calibrating
- Collect 20–40 frames — more diverse frames reduce RMS error
- Check RMS — a good calibration typically achieves RMS < 1.0 px
There are two ways to use the calibrator with ROS 2:
charuco-calibrate --ros-topic /camera/image_rawLazily imports rclpy and cv_bridge — no ROS dependency at install time.
colcon build --packages-select charuco_calibrator_ros
source install/setup.bash
ros2 launch charuco_calibrator_ros calibrator.launch.pyAll board, threshold, and output settings are exposed as ROS parameters:
ros2 run charuco_calibrator_ros charuco_calibrator_node --ros-args \
-p image_topic:=/camera/image_raw \
-p squares_x:=9 \
-p squares_y:=7 \
-p width:=1280 \
-p height:=720 \
-p auto_capture:=trueSee charuco_calibrator_ros/README.md for full setup, parameter list, and troubleshooting.
After calibrating (C) and saving (S), two files are written to output_dir (default calibration_output/):
| File | Contents |
|---|---|
calibration.yaml |
Camera intrinsics in ROS camera_info compatible format |
observations.npz |
Raw corner observations for offline re-calibration |
charuco_calibrator/
config.py # Dataclasses + YAML loading
image_source.py # Camera, video, image folder, and ROS 2 image sources
detector.py # ChArUco detection (OpenCV 4.8+ OO API with legacy fallback)
scoring.py # Frame scoring and coverage tracking
heatmap.py # Gaussian-splat corner heatmap
calibration.py # cv2.calibrateCamera wrapper + YAML export
ui.py # Overlay rendering + keyboard dispatch
main.py # run(cfg) loop + CLI entry point
config/
default_config.yaml
tests/
charuco_calibrator_ros/ # Optional ROS 2 package
MIT