Giter VIP home page Giter VIP logo

camera-calibration's Introduction

Camera-Calibration

Camera Calibration toolbox using Python & openCV

Introduction

Cameras have been around in our lives for a while. When first appeared, they were very expensive. Fortunately, in the late 20th century, the pinhole camera was developed and sold at suitable prices such that everybody was able to afford it. However, as is the case with any trade off, this convenience comes at a price. This camera model is typically not good enough for accurate geometrical computations based on images; hence, significant distortions may result in images.

Camera calibration is the process of determining the relation between the camera’s natural units (pixels) and the real world units (for example, millimeters or inches). Technically, camera calibration estimates intrinsic (camera's internal characteristics such as focal length, skew, distortion) and extrinsic (its position and orientation in the world) parameters. Camera calibration is an important step towards getting a highly accurate representation of the real world in the captured images. It helps removing distortions as well. There are several calibration tools available online, such as:

Here, I create my own calibration toolbox from scratch using python and OpenCV. I follow Zhang’s description in his paper “A flexible new technique for camera calibration,” with allows calibration from multiple 2D plane images. My toolbox is characterized by its friendly user interface, its compatibility to work on any camera and any operation system, and automation such that instead of taking 2D points on captured images individually and manually, a corner detection algorithm automatically handles this task and saves much time and effort.

Installation

  1. Clone or download this repository.

  2. Make sure python 3.x is installed on your PC. To check if and which version is installed, run the following command:

python -V

If this results an error, this means that python isn’t installed on your PC! please install it from the original website

  1. (optional) it is recommended that you create a python virtual environment and install the necessary libraries in it to prevent versions collisions:
python -m venv CV

where CV is the environment name. Once you’ve created a virtual environment, you may activate it.

CV\Scripts\activate.bat
  1. Install required libraries from the provided file (requirements.txt):
pip install -r requirements.txt

Make sure you provide the correct path of requirements.txt

  1. DONE :) Run the script:
python calibration_GUI.py

DEMO

This is the main page of the graphical interface:

image

Check the Detect Corners checkbox and click START. The webcam will start capturing frame and displaying them in the interface:

image

If you are happy with the captured image, click CONFIRM. Otherwise, click IGNORE to take another image. Once you click CONFIRM or IGNORE, the webcam will continue capturing frames, displaying them, and trying to detect corners. The Images taken counter on the top right indicates how many images you have confirmed so far.

image

At least three images are required. The more, the better the parameters estimation. Once you confirm at least three images, you can click DONE on the bottom right. Once clicked:

  • the intrinsic and extrinsic parameters will be calculated. Three files will be created: intrinsic.txt, extrinsic.txt, and predicted VS actual.txt
  • The 2D points of the first confirmed image will be predicted using the following relation:

image

  • To check accuracy, the predicted 2D points will be displayed on the image in the graphical interface as white circles with a plus sign inside.

image

Click here to see the demo as video.

camera-calibration's People

Contributors

obeidaeljundi avatar tehseenhasan 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.