GithubHelp home page GithubHelp logo

swnakamura / pycalib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nbhr/pycalib

0.0 0.0 0.0 21.89 MB

Simple Camera Calibration Examples in Python for Beginners

License: Apache License 2.0

Python 2.16% Jupyter Notebook 97.82% Makefile 0.03%

pycalib's Introduction

Simple Camera Calibration in Python for Beginners

This is a collection of algorithms related to multiple-view camera calibration in computer vision. Please note that the goal of this package is to provide minimal examples to demostrate the concept for beginners (i.e., students). For large-scale, realtime, accurate, robust, production-quality implementations, or for implementations for your specific situation, please consult your advisor.

Disclaimer

This is research software and may contain bugs or other issues -- please use it at your own risk. If you experience major problems with it, you may contact us, but please note that we do not have the resources to deal with all issues.

How to use

You can simply install the package by pip.

$ python3 -m pip install -U pycalib-simple

The pip installation, however, does not include examples in ./ipynb. To run examples, download the repository explicitly. For example,

  1. Local: You can clone/download this repository to your local PC, and open ./ipynb/*.ipynb files by your local Jupyter.
  2. Colaboratory: You can open each Jupyter notebook directly in Google Colaboratory by clicking the Open In Colab buttons below.
    • Warning: Most of them do not run properly as-is, since colab does not clone images used in the Jupyter notebooks. Please upload required files manually. (or run !pip install and !git clone at the beginning of each notebook.)

Single camera

  1. Intrinsic parameters from chessboard images Open In Colab
  2. Extrinsic parameters w.r.t. a chassboard Open In Colab
  3. Intrinsic / Extrinsic parameters from 2D-3D correspondences Open In Colab
  4. Distortion Open In Colab

Multiple cameras

  1. Sphere center detection for 2D-2D correspondences Open In Colab
  2. 2-view extrinsic calibration from 2D-2D correspondences Open In Colab
  3. N-view registration Open In Colab
  4. N-view bundle adjustment Open In Colab

3D-3D

  1. Absolute orientation between corresponding 3D points Open In Colab

If you need to write your own calibration ...

In general, prepare some synthetic dataset, i.e., a toy example, first so that your code can return the exact solution up to the machine epsillon. Then you can try with real data or synthetic data with noise to mimic it.

  1. Linear calibration: Use numpy.
  2. Non-linear (including bundule adjustment): Try scipy.optimize.least_squares first.
    • Implement your objective function as simple as possible. You do not need to consider the computational efficiency at all.
    • If it is unacceptably slow, try the followings in this order.
      1. Ask yourself again before trying to make it faster. Is it really unacceptable? If your calibration can finish in an hour and you do not do it so often, it might be OK for example. "Premature optimization is the root of all evil." (D. Knuth).
      2. Make sure that the optimization runs successfully anyway. In what follows, double-check that the optimization results do not change.
      3. Vectorize the computation with numpy, i.e., no for-loops in the objective function.
        • or use numba (e.g. @numba.jit)
      4. If the system is sparse, use jac_sparsity option. It makes the optimization much faster even without analitical Jacobian.
      5. Implement the analytical Jacobian. You may want to use maxima to automate the calculation.
      6. Reimplement in C++ with ceres-solver if the computation speed is really important.

pycalib's People

Contributors

nbhr avatar shiba6v avatar swnakamura 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.