CAMERA INTRINSICS.
A lens bows straight lines near the edges and the needs to know the focal lengths and the true center of the image. You only need this once, and only if you do geometry with the camera: lane lines on the ground, distances, anything that has to be metric. The standard ROS tool measures it from a checkerboard.
WHAT YOU MEASURE.
Two things come out of this. The camera matrix holds the focal lengths fx, fy and the principal point cx, cy, the real center of the sensor. The distortion coefficients, usually five, describe how the lens bows the image so you can undo it. Together they let you turn a pixel into a ray you can trust.
WHAT YOU'LL NEED.
A checkerboard
The decoded stream
/camera topic carries JPEG bytes, not a plain image, so enable the decode_camera node and calibrate against /camera/decoded.camera_calibration
THE PROCEDURE.
bash# 1. Make sure the decoded image is publishing (decode_camera enabled). ros2 topic echo /camera/decoded --no-arr # 2. Run the calibrator against it. Match --size to the INNER corners of # your board and --square to one square edge in metres. ros2 run camera_calibration cameracalibrator \ --size 7x5 --square 0.035 \ image:=/camera/decoded camera:=/camera # 3. Hold the board in view and move it: left, right, near, far, and # tilted. Watch the X, Y, Size, and Skew bars fill toward green. # 4. When all four bars are full, click CALIBRATE, then SAVE.
A CAMERA_INFO YAML.
Save writes a calibration archive with the intrinsics in the standard camera_info shape. It looks like this, at the camera's 640 by 480 resolution:
yaml# camera_info, written by camera_calibration (values are illustrative) image_width: 640 image_height: 480 camera_name: neoracer_camera camera_matrix: rows: 3 cols: 3 data: [495.2, 0.0, 318.7, 0.0, 496.1, 241.3, 0.0, 0.0, 1.0] distortion_model: plumb_bob distortion_coefficients: rows: 1 cols: 5 data: [0.061, -0.118, 0.0008, -0.0003, 0.0]
The diagonal of the camera matrix is fx, fy; the right column is cx, cy, near but not exactly the image center. That offset is exactly the kind of thing your eye cannot see but your geometry depends on.
USING THE CALIBRATION.
- Point your camera node or a republisher at the saved file so it publishes a matching
camera_infoalongside the image. - Any consumer that undistorts or projects, including the
osracernavigation stack, reads those intrinsics to do honest geometry. - If you only ever use the camera for raw pixels, lane colour, a sign classifier, you can skip this page entirely.
