# yumashino/camera-calibration-with-charuco-board architecture

> Architecture diagram of the GitHub repository yumashino/camera-calibration-with-charuco-board, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yumashino/camera-calibration-with-charuco-board
- Repository: https://github.com/yumashino/camera-calibration-with-charuco-board

## Overview

#### Purpose and Entry Points
This is a local Python/OpenCV utility for calibrating a camera from a video of a ChArUco board. It computes intrinsics, lens distortion, reprojection error, field of view, image-center shifts, and board-to-camera distance statistics.

Primary calibration entry point: `calibrate_camera_with_charuco.py`.  
Board-generation entry point: `generate_charuco_board.py`.

#### Board Definition and Physical Setup
`generate_charuco_board.py` creates the ChArUco target used throughout the calibration workflow. Its dictionary and board grid dimensions must align with the physical board and calibration input.

The calibration configuration supplies physical board measurements plus camera/lens assumptions through YAML, exemplified by `sample_calibration_input.yaml`.

#### Video-to-Detection Stage
`calibrate_camera_with_charuco.py` consumes a video path and YAML configuration. It processes video frames, detects ArUco markers, and interpolates ChArUco corners. Only frames with usable detected corners become calibration observations.

An optional image-display mode exposes the detection boundary for visual validation; the default operational boundary is video input to accumulated corner observations.

#### Calibration Solve
The accepted corner/ID observations and configured board geometry feed OpenCV’s ChArUco calibration routines. The solve produces the camera matrix (`fx`, `fy`, `cx`, `cy`), distortion coefficients, and RMS reprojection error.

This stage depends on the OpenCV contrib ArUco APIs, whose version is materially constrained by `requirements.txt`.

#### Derived Camera and Pose Metrics
After calibration, the program derives horizontal/vertical field of view and principal-point shifts from the solved intrinsics. Per-observation board pose/distance estimates are aggregated into mean, variance, and standard deviation distance metrics.

These results represent calibration quality and capture-coverage diagnostics, rather than a persistent runtime service.

#### Output Contract
Results are serialized as a timestamped YAML file associated with the input video. The expected schema is demonstrated in `sample_calibration_input_results_20240210_2131.yaml`, including matrix, distortion, reprojection error, detected-frame count, FOV, shifts, and distance statistics.

The repository also includes `sample_calibration_video.mp4` as a local sample input artifact.

#### Runtime and Infrastructure
Runtime is standalone Python 3.6+ with dependencies installed from `requirements.txt`; no server, database, cloud infrastructure, or external API is indicated. Inputs and outputs are local filesystem artifacts: video, YAML configuration, generated board image, and calibration-results YAML.

Main entry points: [`calibrate_camera_with_charuco.py`](https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/calibrate_camera_with_charuco.py) (Intrinsic calibration solve), [`sample_calibration_input.yaml`](https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/sample_calibration_input.yaml) (Calibration configuration), [`requirements.txt`](https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/requirements.txt) (OpenCV contrib ArUco), [`sample_calibration_input_results_20240210_2131.yaml`](https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/sample_calibration_input_results_20240210_2131.yaml) (Timestamped results YAML)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_board["Board setup"]
  node_board_generator["Board generator<br/>Python entry point"]
  node_charuco_board["ChArUco board image<br/>generated target"]
end

subgraph group_calibration["Calibration pipeline"]
  node_calibration_script["Camera calibration<br/>Python entry point"]
  node_frame_detection["Frame corner detection<br/>OpenCV ArUco stage"]
  node_observations["Accepted observations<br/>corner IDs and points"]
  node_calibration_solve["Intrinsic calibration solve<br/>OpenCV ChArUco stage"]
  node_derived_metrics["Camera and pose metrics<br/>analysis stage"]
  node_display_mode["Detection display mode<br/>optional visual validation"]
end

subgraph group_artifacts["Local artifacts"]
  node_video_input["Calibration video<br/>local MP4 input"]
  node_yaml_config["Calibration configuration<br/>local YAML input"]
  node_results_yaml["Timestamped results YAML<br/>local YAML output"]
end

node_opencv_aruco["OpenCV contrib ArUco<br/>runtime dependency<br/>[requirements.txt]"]
node_python_runtime["Python 3.6+<br/>local runtime"]

node_board_generator -->|"generates"| node_charuco_board
node_charuco_board -.->|"dimensions must align"| node_yaml_config
node_python_runtime -->|"runs"| node_calibration_script
node_opencv_aruco -->|"detects corners"| node_frame_detection
node_opencv_aruco -->|"solves calibration"| node_calibration_solve
node_video_input -->|"input"| node_calibration_script
node_yaml_config -->|"board and lens settings"| node_calibration_script
node_calibration_script -->|"processes frames"| node_frame_detection
node_frame_detection -->|"retains usable frames"| node_observations
node_frame_detection -.->|"optional visualization"| node_display_mode
node_observations -->|"corner observations"| node_calibration_solve
node_yaml_config -->|"board geometry"| node_calibration_solve
node_calibration_solve -->|"intrinsics and error"| node_derived_metrics
node_observations -->|"per-frame poses"| node_derived_metrics
node_calibration_solve -->|"calibration results"| node_results_yaml
node_derived_metrics -->|"derived diagnostics"| node_results_yaml

click node_board_generator "https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/generate_charuco_board.py"
click node_calibration_script "https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/calibrate_camera_with_charuco.py"
click node_frame_detection "https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/calibrate_camera_with_charuco.py"
click node_calibration_solve "https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/calibrate_camera_with_charuco.py"
click node_derived_metrics "https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/calibrate_camera_with_charuco.py"
click node_display_mode "https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/calibrate_camera_with_charuco.py"
click node_video_input "https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/sample_calibration_video.mp4"
click node_yaml_config "https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/sample_calibration_input.yaml"
click node_results_yaml "https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/sample_calibration_input_results_20240210_2131.yaml"
click node_opencv_aruco "https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/requirements.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_board_generator,node_charuco_board toneBlue
class node_calibration_script,node_frame_detection,node_observations,node_calibration_solve,node_derived_metrics,node_display_mode toneAmber
class node_video_input,node_yaml_config,node_results_yaml toneMint
class node_opencv_aruco,node_python_runtime toneNeutral
```

## Components

### Board setup

- [Board generator](https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/generate_charuco_board.py): Python entry point · Creates the physical ChArUco target image. · `generate_charuco_board.py`
- **ChArUco board image**: generated target

### Calibration pipeline

- [Camera calibration](https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/calibrate_camera_with_charuco.py): Python entry point · Standalone video-based calibration workflow. · `calibrate_camera_with_charuco.py`
- [Frame corner detection](https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/calibrate_camera_with_charuco.py): OpenCV ArUco stage · Detects markers and interpolates ChArUco corners per video frame. · `calibrate_camera_with_charuco.py`
- **Accepted observations**: corner IDs and points · Only frames with usable ChArUco corners are retained.
- [Intrinsic calibration solve](https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/calibrate_camera_with_charuco.py): OpenCV ChArUco stage · Computes camera matrix, distortion, and RMS reprojection error. · `calibrate_camera_with_charuco.py`
- [Camera and pose metrics](https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/calibrate_camera_with_charuco.py): analysis stage · Derives FOV, principal-point shifts, and distance statistics. · `calibrate_camera_with_charuco.py`
- [Detection display mode](https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/calibrate_camera_with_charuco.py): optional visual validation · `calibrate_camera_with_charuco.py`

### Local artifacts

- [Calibration video](https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/sample_calibration_video.mp4): local MP4 input · `sample_calibration_video.mp4`
- [Calibration configuration](https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/sample_calibration_input.yaml): local YAML input · Provides board measurements and camera/lens assumptions. · `sample_calibration_input.yaml`
- [Timestamped results YAML](https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/sample_calibration_input_results_20240210_2131.yaml): local YAML output · Contains solved parameters, quality metrics, and diagnostics. · `sample_calibration_input_results_20240210_2131.yaml`

### Other components

- [OpenCV contrib ArUco](https://github.com/yumashino/camera-calibration-with-charuco-board/blob/main/requirements.txt): runtime dependency · Version-constrained ChArUco detection and calibration APIs. · `requirements.txt`
- **Python 3.6+**: local runtime

## Connections

- Board generator → ChArUco board image: generates
- ChArUco board image → Calibration configuration: dimensions must align
- Python 3.6+ → Camera calibration: runs
- OpenCV contrib ArUco → Frame corner detection: detects corners
- OpenCV contrib ArUco → Intrinsic calibration solve: solves calibration
- Calibration video → Camera calibration: input
- Calibration configuration → Camera calibration: board and lens settings
- Camera calibration → Frame corner detection: processes frames
- Frame corner detection → Accepted observations: retains usable frames
- Frame corner detection → Detection display mode: optional visualization
- Accepted observations → Intrinsic calibration solve: corner observations
- Calibration configuration → Intrinsic calibration solve: board geometry
- Intrinsic calibration solve → Camera and pose metrics: intrinsics and error
- Accepted observations → Camera and pose metrics: per-frame poses
- Intrinsic calibration solve → Timestamped results YAML: calibration results
- Camera and pose metrics → Timestamped results YAML: derived diagnostics
