Background reading
Study sections 13.1 and 13.2 of Peter Corke’s textbook Robotics, Vision and Control (RVC3). The book’s GitHub repo and the Chapter 13 notebook script contain reference code.Zhang’s method
Zhang’s method estimates camera parameters from multiple views of a planar calibration pattern (typically a checkerboard). The method consists of three stages:- DLT (Direct Linear Transform) initialization — compute an initial estimate of the homography between the calibration pattern and each image.
- Closed-form intrinsic parameter extraction — recover the camera matrix from the homographies.
- Non-linear refinement — refine all parameters (intrinsics + extrinsics for each view) by minimizing reprojection error using SGD or Levenberg-Marquardt.
Test dataset
Use the pantelism/wide-camera-calibration HuggingFace dataset as test images (Parquet format):Capturing your own calibration images
- Print the 9x7 checkerboard pattern and attach it to a rigid flat surface.
- Using your smartphone or webcam at a fixed zoom level, capture at least 15 images from different angles, distances, and orientations.
- Ensure good, diffuse lighting; keep the pattern flat and in focus
- Disable autofocus and set a fixed focus for the duration
- Capture from many positions and angles, up to about 45 degrees
- Ensure the pattern fills a significant portion of the field of view
- Avoid perfectly frontal views — angled views provide more information
- Capture both wide shots and close-ups
Calibration outputs
After calibration, report:- Camera matrix (focal lengths , and principal point , )
- Distortion coefficients (, , , , )
- Reprojection error (RMS, in pixels)
- Undistorted vs. distorted image comparisons
- Radial distortion profile (distortion factor vs. radial distance from center)
Pose estimation with a calibrated camera (ROS 2)
Once calibrated, the camera parameters enable object pose estimation:-
Use OpenCV’s
solvePnPto estimate the relative pose of objects from the camera, given known 3D geometry and 2D detections. Alternatively, use ArUco fiducial markers withcv2.aruco. - Establish a world coordinate system using fixed objects to compute the camera pose (rotation + translation) in the world frame.
-
In ROS 2, calibration parameters are published on the
/camera_infotopic:
OpenCV reference solution
The reference notebook implements the full calibration pipeline using OpenCV — corner detection, calibration, undistortion, reprojection error analysis, and distortion profiling.Camera Calibration Notebook
OpenCV reference solution for camera calibration with the HuggingFace dataset.

