This Python application provides a user-friendly tool for camera calibration and perspective correction. It uses the OpenCV library for computer vision tasks and PyQt5 for the graphical user interface.
-
Camera Calibration Tab:
- Capture checkerboard pattern images for precise camera calibration.
- Adjustable settings for checkerboard dimensions (columns, rows, square size).
- Real-time camera feed displaying detected checkerboard corners.
- Option to save images with detected corners for subsequent calibration.
-
Calibration Process:
- Automated detection of corners in calibration images.
- Visualization and saving of calibration results, including the camera matrix and distortion coefficients.
-
Testing and Saving Calibration:
- Apply calibration to a live camera feed for immediate feedback.
- Persist calibration parameters as a JSON file for future use.
-
Importing Calibration Data:
- Import existing calibration parameters from a JSON file.
- Apply previously saved calibration data, bypassing the need for recalibration.
-
Perspective Warping Functionality:
- Load images for perspective correction.
- Interactive selection of landmarks for perspective transformation.
- Live preview of perspective-corrected images.
-
Tuning and Enhancing Images:
- Fine-tune perspective warping parameters for optimal results. Use keys 1,2,3 and 4 to select landmark and arrow keys to tune.
- Saving the results to binary file (TODO)
Tested on Ubuntu 22.04 LTS (Should work on Ubuntu 20.04 LTS also)
-
Clone the repository:
git clone https://github.com/DXM123/camera_calibration.git
-
Ensure OpenCV is installed. If not, install it using:
sudo apt-get install python3-opencv
-
Install other required packages (
numpy
,PyQt5
,pypylon
and PyQt5 dependencylibxcb-xinerama0
):python3 -m pip install --upgrade pip python3 -m pip install -r requirements.txt
-
Run the script.
./calibration-gui.py
Calibration Example:
Warp Example: