AutoCalib: Camera Calibration from Scratch

AutoCalib is a complete implementation of camera intrinsic calibration built entirely from first principles using NumPy, OpenCV, and SciPy — without relying on OpenCV’s built-in calibration functions. The system recovers the camera intrinsic matrix and distortion coefficients from checkerboard images using Zhang’s calibration method.


Calibration Pipeline

1. Corner Detection — Checkerboard corners are detected in 13 calibration images using cv2.findChessboardCorners with sub-pixel refinement via cv2.cornerSubPix.

2. Homography Estimation — For each image, a homography between the checkerboard world plane and the image plane is computed from scratch using SVD (Singular Value Decomposition).

3. Intrinsic Matrix Estimation — Zhang’s method constructs a system of equations from the homographies, solved via SVD to recover the 5-parameter intrinsic matrix K (focal lengths, principal point, skew).

4. Extrinsic Recovery — Rotation and translation matrices are extracted from each homography using the calibrated K.

5. Non-Linear Optimization — All parameters (intrinsics + extrinsics + radial distortion coefficients k₁, k₂) are refined jointly using Levenberg-Marquardt via scipy.optimize.least_squares, minimizing reprojection error.


Reprojection Results

Red circles show the reprojected checkerboard corners overlaid on undistorted calibration images, validating the accuracy of the recovered camera parameters.

Reprojected 0
Reprojected 1
Reprojected 4
Reprojected 5
Reprojected 8
Reprojected 11

View Code on GitHub