Skip to main content

No project description provided

Project description

Camera Calibration

Created on Sunday, April 21, 2024
Author: Tung Nguyen - Handsome
Reference: Camera Calibration by OpenCV (OpenCV Tutorial)

Banner Tung Handsome Camera Calibration

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.

    from camera_calibration import CameraCalibration
    
  2. Create an instance of CameraCalibration.

    camera_calibrator = CameraCalibration()
    
  3. Calculate calibration data using a set of images with known chessboard pattern.

    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)

    calibrator.read_calibration_data(r"calibration.pkl", "pkl", True)
    
  5. Undistort an image. (If not calculate calib data from scratch, require to read calib data first)

    undistorted_image = camera_calibrator.undistortion_img(
        img,
        method="default",
        img_size=(1280, 720),
        verbose=False
    )
    

    or

    undistorted_image = camera_calibrator.undistortion_img(
        img,
        method="Remapping",
        img_size=(1280, 720),
        verbose=False
    )
    

Results

💚🖤 Join me on Social Media 🖤💚

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TH_camera_calibration-0.4.10.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

TH_camera_calibration-0.4.10-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file TH_camera_calibration-0.4.10.tar.gz.

File metadata

  • Download URL: TH_camera_calibration-0.4.10.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for TH_camera_calibration-0.4.10.tar.gz
Algorithm Hash digest
SHA256 cee8edce1597ba80c108163934fe6ba6da4f65d7fafad6d12b99b3be1c39ee12
MD5 5478ec243f4776f74047c4e98112ca53
BLAKE2b-256 e578ba8fbffdce3219dc6899c5c6aad6f517b6a77087adea4cd6262b1a50b11b

See more details on using hashes here.

File details

Details for the file TH_camera_calibration-0.4.10-py3-none-any.whl.

File metadata

File hashes

Hashes for TH_camera_calibration-0.4.10-py3-none-any.whl
Algorithm Hash digest
SHA256 11f6c0c9199dba260dee805ee42933a7ca7f02a318a6b066ea210ed8b9c9e40f
MD5 7fda940404aa1fc1e26dcfbb640f5d32
BLAKE2b-256 e3105c400e1dac62bb8167bdbdd1a5608905df30ee294b4fc2a9cadb1aec463d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page