Git Product home page Git Product logo

tf_calib's Introduction

Tensorflow calibrator

Tensorflow camera calibrator

Prerequisites

sudo pip3 install numpy, scipy, tensorflow_gpu

The example data is collected using my Logitech C 310 webcam.

After 10 epochs we reach precision < 10-2 size of the quare (~7cm)

Theory

Pinhole camera

Our goal is to find the camera matrix K together with distortion coefficients, the so-called intrinsic parameters of the camera.

The camera matrix reads:

,

where fx, fy are focal lengths of the camera and cx, cy are the pixel coordinates of the principal point.

The distortion coefficients depend on the model. Currently we have implemented only simple radial distortion coefficients k1, k2, k3 from OpenCV docs.

The world coordinates (x1,x2,x3) in the camera coordinate system are related to the pixel coordinates (ξ12,1) via the camera matrix as follows:

with a scale parameter s, which corresponds to the arbitrary scale due to the fact that the camera projects an entire ray to a single point.

The inverse of this relation looks as follows:

(1)

The vectors ui define the ray corresponding to the i-th point.

Minimization

Let ciα be the coordinates of a calibration pattern in its own coordinate system. Here and further the latin index i runs from 1 to N, where N is the number of points in the calibration pattern. Greek indices α,β... run from 1 to 3. Note that we do not assume anything about the structure of the calibration pattern.

Now, let ξiα be the pixel coordinates of the ith pattern point on the image.

Assuming the camera intrinsic parameters are known we can find a rotation matrix R and a translation vector T which, together with the scale parameters si, minimize the following error:

The quantities u are defined in (1). We equipped the variables from the previous section with additional index i, which indicates the number of the point in the calibration pattern.

Indeed, sequientially taking the derrivatives of E by si, T, and R and equaling them to zero we obtain the following expressions for (1):

(2)

Here we defined the following auxilliary quantities:

The projector alogn ui

,

The projection of the rotated vector Rci on the line ui

,

The sum of projectors and its inverse:

,

With this notations the matrix U looks:

, (3)

where J N is NxN all-one matrix matrix and I 's are identity matrices of the corresponding dimensions.

The definition (3) in the operator notations reads:

The rotation matrix is determined from the following equation:

(4)

where the matrix M reads:

To summarize, the algorithm for determining the parameters K is the following:

  1. Initialize K
  2. For each image
    1. Solve the equation (4) with respectto R subject to RTR = I
    2. Apply gradients descent to parameters K with loss function (2)

Note that the parameters K are hidden in the vectors u.

tf_calib's People

Contributors

vahagniv avatar

Watchers

James Cloos 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.