Skip to content

AutoCalib-Camera Calibration implements Zhengyou Zhang’s seminal method from scratch. It computes homographies via DLT, extracts initial parameters using SVD, and refines them with MLE to accurately estimate intrinsic parameters and distortion coefficients for robust camera modeling.

Notifications You must be signed in to change notification settings

Prasham2181/AutoCalib-Camera-Calibration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Camera Calibration using Zhang's Method

A Python implementation of Zhang's camera calibration technique using a planar checkerboard pattern. This project provides tools for estimating both intrinsic and extrinsic camera parameters through checkerboard corner detection, homography computation, and non-linear optimization.

Features

  • Automatic checkerboard corner detection and sub-pixel refinement
  • Intrinsic camera parameter estimation (focal length, principal point)
  • Extrinsic parameter computation (rotation, translation) for each calibration image
  • Lens distortion correction (radial distortion coefficients k₁, k₂)
  • Visualization tools for calibration quality assessment
  • Image undistortion capabilities

Overview

The calibration pipeline follows these key steps:

  1. Image Acquisition and Corner Detection

    • Process multiple JPEG calibration images
    • Automatic checkerboard corner detection using OpenCV
    • Sub-pixel corner refinement for improved accuracy
  2. Initial Parameter Estimation

    • Homography computation using Direct Linear Transform (DLT)
    • Intrinsic parameter extraction from homography constraints
    • Per-image extrinsic parameter estimation (R, t)
  3. Non-Linear Parameter Refinement

    • Joint optimization of all parameters
    • Minimization of reprojection error
    • Estimation of lens distortion coefficients
    • Bundle adjustment for improved accuracy
  4. Visualization and Validation

    • Image undistortion using calibrated parameters
    • Overlay of detected vs. reprojected corners
    • Reprojection error visualization and statistics

Installation

Prerequisites

  • Python 3.x
  • OpenCV
  • NumPy
  • SciPy

Setup

# Clone the repository
git clone https://github.com/yourusername/camera-calibration.git
cd camera-calibration

# Install required packages
pip install opencv-python numpy scipy

Usage

# Example code snippet for running calibration
from calibration import CameraCalibration

# Initialize calibrator
calibrator = CameraCalibration()

# Add calibration images
calibrator.add_images('path/to/calibration/images/*.jpg')

# Run calibration
calibrator.calibrate()

# Get calibration results
K, dist_coeffs = calibrator.get_parameters()

# Undistort an image
undistorted = calibrator.undistort_image(image)

Results

Original Checkerboard Images

Checkerboard 1 Checkerboard 2
Checkerboard 1 Checkerboard 2

Corner Detection and Reprojection

Reprojection 1 Reprojection 2
Reprojection 1 Reprojection 2

Undistorted Results

Undistorted 1 Undistorted 2
Undistorted Image 1 Undistorted Image 2

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use this implementation in your research, please cite:

@article{zhang2000flexible,
  title={A flexible new technique for camera calibration},
  author={Zhang, Zhengyou},
  journal={IEEE Transactions on pattern analysis and machine intelligence},
  volume={22},
  number={11},
  pages={1330--1334},
  year={2000},
  publisher={IEEE}
}

About

AutoCalib-Camera Calibration implements Zhengyou Zhang’s seminal method from scratch. It computes homographies via DLT, extracts initial parameters using SVD, and refines them with MLE to accurately estimate intrinsic parameters and distortion coefficients for robust camera modeling.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages