Code Monkey home page Code Monkey logo

discorpy's Introduction

Discorpy

(Dis)tortion (Cor)rection (Py)thon-package

Camera calibration and distortion correction software for lens-based detector systems

GitHub Workflow Status Downloads former_vounwarp_downloads Anaconda-Server Badge Documentation Status Anaconda-Server Badge GitHub code size in bytes Anaconda-Server Badge Coverage

Discorpy is an open-source Python package designed for camera calibration and distortion correction with sub-pixel accuracy. It calculates parameters of correction models using a grid pattern image. Primarily, the package implements methods published in Optics Express and offers a comprehensive pipeline for data processing. Starting from version 1.4, the package also includes perspective distortion correction capabilities.

Author and maintainer: Nghia Vo, NSLS-II, Brookhaven National Laboratory, US; Diamond Light Source, UK.

Features

  • The polynomial model used by the package is versatile enough to calibrate images with varying levels of radial distortion. This practical feature eliminates the need for users to switch between different models based on the degree of distortion in the images.
  • Discorpy offers a unique feature where radial distortion, the center of distortion, and perspective distortion can be independently determined and corrected using a single calibration image.
  • The software provides a full pipeline of data processing including:
    • Pre-processing methods for: extracting reference-points from a dot-pattern image, line-pattern image, and chessboard (checkerboard) image; grouping these points line-by-line.
    • Processing methods for calculating the optical center, coefficients of polynomial models for correcting radial distortion, and parameters of a model for correcting perspective distortion.
    • Post-processing methods for: unwarping lines of points, images, or slices of a 3D dataset; and evaluating the accuracy of the correction results.
    • Some methods may be useful for other applications:

Installation

Documentation

Usage

Demonstrations

  • Detailed step-by-step demonstrations featuring codes and explanations of how to use Discorpy for various types of calibration images are shown here.

  • Apply to a visible dot-target collected at Beamline I12, Diamond Light Source, UK:

    I12_before_after1

    I12_before_after2

  • Apply to an X-ray dot-target collected at Beamline I13, Diamond Light Source, UK:

    I13_before_after1

    I13_before_after2

  • Improvement of tomographic reconstructed images after distortion correction:

    • For a detector with strong radial distortion:

      tomo_strong

    • For a detector with small radial distortion:

      tomo_small

  • Calibrate a commercial camera with capabilities of correcting radial distortion and perspective distortion independently.

    show_case

  • Calibrate a laptop webcam using a checkboard image.

    webcam_before

    webcam_after

  • Apply to a hazard camera of the Mars Perseverance Rover. Details of how to estimate distortion coefficients of that camera without using a calibration target are shown here.

    Percy_cam1

    Percy_cam2

  • Correct perspective distortion:

    perspective_correction

discorpy's People

Contributors

markbasham avatar nghia-vo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discorpy's Issues

Issue in removing fisheye effect from face

Hi Developers,
I want to remove fisheye distortion from a face, I tried with every possible way but not get a proper output.
I am trying since last 1 month but not getting success.

I came to know about this discorpy library, can this library help to remove fisheye distortion from a face.
I will share one sample frame of my video from which I want to remove fisheye distortion.

Frame0

Please reply soon.
Thanks in advance !

generate_4_source_target_perspective_points function question

Hi there,

I'm working on a camera calibration-related project and I found this library very useful. However, I'm currently stuck on understanding
def generate_4_source_target_perspective_points(points, input_order="yx", equal_dist=False, scale="mean"):
specifically, this section where you obtained target points from source points. I have trouble figuring out the **y1 = (a0 * b3 + b1) / (1.0 + a0 ** 2)**. I wonder if you could provide me with a reference on this part. Many thanks!

dist_h, dist_v = dist_h * 0.5, dist_v * 0.5 b1 = bh - np.abs(dist_v / np.cos(np.arctan(a0))) b2 = bh + np.abs(dist_v / np.cos(np.arctan(a0))) b3 = bv - np.abs(dist_h / np.cos(np.arctan(a0))) b4 = bv + np.abs(dist_h / np.cos(np.arctan(a0))) y1 = (a0 * b3 + b1) / (1.0 + a0 ** 2) x1 = -a0 * y1 + b3 y2 = (a0 * b4 + b1) / (1.0 + a0 ** 2) x2 = -a0 * y2 + b4 y3 = (a0 * b3 + b2) / (1.0 + a0 ** 2) x3 = -a0 * y3 + b3 y4 = (a0 * b4 + b2) / (1.0 + a0 ** 2) x4 = -a0 * y4 + b4 target_points = np.asarray([[y1, x1], [y2, x2], [y3, x3], [y4, x4]]) return source_points, target_points

[Help wanted] Distortion Correction For a binary grid image

Hello, dear authors! I want to do distortion correction for binary image like this
image
but it seems not that easy to locate every intersection of the lines, so I decided to use the center of every box to do the correction, like this:
image
I noticed that discorpy has the function of correcting both radial distortion and perspective distortion. Is there any way to use these points to do the correction?
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.