Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nguyenquangtung/camera_calibration
Easy_to_use package for Camera Calibration
https://github.com/nguyenquangtung/camera_calibration
calibration camera-calibration opencv python vision
Last synced: about 1 month ago
JSON representation
Easy_to_use package for Camera Calibration
- Host: GitHub
- URL: https://github.com/nguyenquangtung/camera_calibration
- Owner: nguyenquangtung
- Created: 2024-04-16T02:58:25.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-05-04T11:18:13.000Z (7 months ago)
- Last Synced: 2024-10-12T14:29:53.706Z (about 1 month ago)
- Topics: calibration, camera-calibration, opencv, python, vision
- Language: Python
- Homepage: https://pypi.org/project/TH-camera-calibration/
- Size: 130 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Camera Calibration
Created on Sunday, April 21, 2024
Author: Tung Nguyen - Handsome
Reference: Camera Calibration by OpenCV ([OpenCV Tutorial](https://docs.opencv.org/4.x/dc/dbb/tutorial_py_calibration.html))![Banner Tung Handsome Camera Calibration](https://github.com/nguyenquangtung/Camera_Calibration/assets/59195029/023dd5de-9801-44c7-a990-176921246aa8)
## Overview
This Python script provides a class, `CameraCalibration`, to perform camera calibration based on a set of image points and their corresponding object points / undistort image or frame from camera
## Description
This script includes functionalities to:
- Calculate camera calibration data based on a set of images.
- Save and load the camera calibration data.
- Undistort images or points using the calibration data.## Usage
Using this command to install the packages (or clone this repository):
```
pip install TH-camera-calibration
```### Requirements
- Python 3.x
- OpenCV
- Numpy
- PyYAML (For working with YAML files)
To set up the environment, install all the required libraries by using this command:```
pip install -r requirements.txt
```### How to Use
1. Import the `CameraCalibration` class from `camera_calibration.py`.
```python
from camera_calibration import CameraCalibration
```2. Create an instance of `CameraCalibration`.
```python
camera_calibrator = CameraCalibration()
```3. Calculate calibration data using a set of images with known chessboard pattern.
```python
camera_calibrator.calculate_calibration_data(
run=True,
chessboardSize=(9, 6),
size_of_chessboard_squares_mm=25,
framesize=(1280, 720),
calibrationDir=None, #path of calibration dir
savepath="",
saveformat="pkl",
show_process_img=True,
show_calibration_data=True,
)
```
4. Read calibration data. (run when have calib data already and do not want to calculate calib data from scratch)
```python
calibrator.read_calibration_data(r"calibration.pkl", "pkl", True)
```
6. Undistort an image. (If not calculate calib data from scratch, require to read calib data first)```python
undistorted_image = camera_calibrator.undistortion_img(
img,
method="default",
img_size=(1280, 720),
verbose=False
)
```or
```python
undistorted_image = camera_calibrator.undistortion_img(
img,
method="Remapping",
img_size=(1280, 720),
verbose=False
)
```## Results
## 💚🖤 Join me on Social Media 🖤💚
- My Gmail: [email protected]
- My Github: [Tung Nguyen - Handsome - Github](https://github.com/nguyenquangtung)
- My Youtube channel: [Tung Nguyen - Handsome - Youtube](https://www.youtube.com/@tungquangnguyen731)
- My Linkedin: [Tung Nguyen - Handsome - Linkedin](https://www.linkedin.com/in/tungnguyen73/)