Add a camera calibration tool and a checkerboard to show on a screen

hermes_vision.calibrate collects 20 varied checkerboard views from the camera topic
(rejecting repeats of a pose, which constrain nothing), solves with OpenCV and writes
the camera_info YAML camera_ros loads, named with the resolution as it expects.
Tested: the solver recovers a known synthetic camera (focal length within 1%), the
YAML round-trips, and real board detection works on a rendered board. Not yet run on
the real camera: it needs someone holding a board in front of it, with the focus set.

docs/checkerboard-9x6.png is a 10x7-square board that can be shown on a screen.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFN8nRRCiDiMN7ChBpHJhs
This commit is contained in:
2026-10-05 00:52:09 -07:00
co-authored by Claude Sonnet 5.5
parent 9952c92bc5
commit 497f026dc9
6 changed files with 239 additions and 3 deletions
+16
View File
@@ -130,6 +130,22 @@ give MCP images to the main model: it saves the photo to its image cache and the
- **Run a node by hand:** `source ~/robot-env.sh` first: it puts the libcamera fork and the right
OpenCV on the path, and keeps ROS local.
## Calibrating the camera
Needed once, and again if you change the lens focus or the image size. Set the focus first (the lens
turns if it is not glued: focus at the distance you will use), then show `docs/checkerboard-9x6.png`
on a screen (or print it) and measure one square with a ruler. With the robot running, on the Pi, after
`source ~/robot-env.sh`:
```
python3 -m hermes_vision.calibrate --cols 9 --rows 6 --square-mm <measured>
```
Hold the camera 25 to 60 cm from the board and vary distance, tilt and position, keeping all of it in
view. It collects 20 different views, solves with OpenCV and writes
`~/.ros/camera_info/ov5647__base_soc_i2c0mux_i2c_1_ov5647_36_1296x972.yaml`. A reprojection error under
about 0.5 px is good. `sudo systemctl restart robot` to load it.
## Tuning and troubleshooting
- **Recordings are exactly silent:** the Audio switch is off (see above).