This repository contains a Python script to calibrate a camera using a set of chessboard images. It leverages OpenCV for image processing and calibration, as well as NumPy and Matplotlib for data management and visualization.
# Clone the repository
$ git clone https://github.com/<your-github-username>/camera-calibration.git
# Navigate to the project folder.
$ cd camera-calibration
# Create the Conda environment.
$ conda env create -f environment.yml
# Activate the new environment.
$ conda activate xvision
camera-calibration/
│
├── main_script.py # Main Python script
├── images/ # Directory for chessboard images
├── info/ # Optional: Directory for output files
└── environment.yml # Conda environment file
- Ensure your chessboard images for calibration are inside the images/ folder.
- Open a terminal and navigate to the project directory.
- Run the main script:
$ python calibration.py
- Automatic Chessboard Detection: Reads images from images/ and detects chessboard corners.
- Camera Calibration: Calibrates the camera using detected points.
- Parameter Persistence: Saves calibration parameters in both text and .npz formats.
- Calibration Validation: Displays a sample undistorted image and calculates the error rate of the calibration.
info/calibration.npz: This NumPy file contains the camera matrix, distortion coefficients, rotation vectors, and translation vectors.