Giter Club home page Giter Club logo

defisheye's Introduction

defisheye

Python scripts for unwarping the images produced by a fisheye lens.

Code is adapted from Kenneth Jiang from this Medium article, which can be referenced for a more in-depth explanation.

Example

Input

Output

Setup

Install pip packages

python3 -m venv env; source env/bin/activate
pip install -r requirements.txt

Calibrate to your specific fisheye lens

Every lens is different so we must calibrate our program to our lens.

To obtain the proper calibration settings for our lens, we must:

  • Print this checkerboard image on regular sized printer paper.
  • Stick the checkerboard image we just printed onto a flat surface. A clipboard, or in my case, a shoebox works fine. The key here is the checkerboard must be flat.
  • Capture photos of the printed checkerboard from multiple angles using our fisheye lens. We should take photos from as many angles as possible. 30+ photos from different angles will suffice.
  • Replace the photos in the photos directory with the photos captured in the previous step. These should be png or jpg format.

Then to obtain our calibration settings (saved to calibrate_config.py):

python calibrate.py

Remove fisheye distortion

# Remove fisheye and resize image to fit original image size (black around edge is cropped)
python defisheye.py input.jpg

# Remove fisheye and keep entire image
python defisheye_retain_all.py input.jpg

The balance value [0, 1.0] used in defisheye_retain_all.py can be modified to crop more or less of the black around the edge of the undistorted image. For example balance=0.0 will produce cropped output with no black edges while balance=1.0 will produce uncropped output. By default, balance is set to 1.0.

defisheye's People

Contributors

nsevent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.