Skip to main content

Camera Calibration

Learn how to calibrate cameras to correct lens distortion and obtain accurate 3D measurements from images.

Why Camera Calibration?

Camera calibration is essential for:
  • Removing lens distortion from images
  • Measuring real-world dimensions from images
  • 3D reconstruction and depth estimation
  • Augmented reality applications
  • Accurate object tracking and positioning

Camera Parameters

Internal camera properties:
  • Focal length (fx, fy): Distance from lens to sensor
  • Principal point (cx, cy): Image center offset
  • Skew coefficient: Axis skewness (usually 0)
  • Distortion coefficients: Radial and tangential distortion
Represented as camera matrix K:
Camera position and orientation in world space:
  • Rotation matrix (R): 3x3 matrix
  • Translation vector (t): 3x1 vector
Transforms world coordinates to camera coordinates:
Lens distortion parameters:
  • k1, k2, k3: Radial distortion
  • p1, p2: Tangential distortion
Distortion model:

Calibration Pattern

The most common calibration pattern is a chessboard:

Creating a Chessboard Pattern

1

Generate Pattern

Print a chessboard pattern with known square size (e.g., 25mm). Common sizes:
  • 9x6 inner corners (10x7 squares)
  • 8x6 inner corners (9x7 squares)
2

Mount on Flat Surface

Attach the pattern to a rigid, flat surface (cardboard, acrylic, etc.)
3

Capture Images

Take 15-30 images of the pattern from different angles and distances
Chessboard requirements:
  • High contrast between squares
  • Perfectly flat surface
  • No glare or reflections
  • Pattern fills 30-70% of image
  • Vary viewing angles (tilt, rotate, distance)

Camera Calibration Process

Based on OpenCV’s calibrate.py sample:

Single Camera Calibration

Undistorting Images

Basic Undistortion

Efficient Undistortion with Remapping

For real-time video, precompute undistortion maps:

Calibration Quality Assessment

Calibration quality guidelines:
  • RMS error < 0.5: Excellent
  • RMS error < 1.0: Good
  • RMS error > 1.0: May need more images or better pattern detection
Tips for better calibration:
  • Use 15-30 images minimum
  • Cover all areas of the image
  • Include tilted views (30-45 degrees)
  • Vary distances to pattern
  • Ensure sharp, well-lit images
  • Use higher resolution if possible

Stereo Calibration

Calibrate two cameras for stereo vision:
Common calibration mistakes:
  • Too few images (minimum 15 recommended)
  • Images too similar (vary angles and distances)
  • Motion blur or poor lighting
  • Chessboard not flat or warped
  • Pattern detection failures ignored
  • Not checking reprojection error

Practical Applications

After calibration, you can measure distances between points:
Use calibration for accurate AR overlay:
Combine with stereo vision:

Next Steps

  • Apply calibration to Video Processing
  • Use with Deep Learning for accurate 3D object detection
  • Explore stereo vision and depth estimation
  • Learn about pose estimation and AR applications