ibois-epfl / rgb-camera-calibration

Repository for calibrate ssimple rgb cameras.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rgb-camera-calibration

Repository for calibrate simple monocular rgb cameras with opencv library.

How it works

[1] Capture images with:

./capture_img.py -I 2

Where -I 2 indicates the index of the camera in respect to your usb ports.

[2] For running the calibration use the tag -H for the horizontal intern corners of the chessboard's squares, -V the same for the vertical and -S for the size in mm of a single square:

./calibrate_camera.py -H 19 -V 13 -S 20

You will get out a json like this one:

{
"cameraMatrix": [
[
586.1448732152043,
0.0,
351.5693629062192
],
[
0.0,
586.0889104493665,
252.2586424474363
],
[
0.0,
0.0,
1.0
]
],
"distortion": [
[
-0.4718410631204992,
0.5349257342222979,
0.000554711180662626,
0.0011910645805549556,
-0.569890258634048
]
]
}

and a opencv yml like this:

%YAML:1.0
---
image_width: 640
image_height: 480
camera_matrix: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [ 9.2730004245864950e+02, 0., 3.5689035902355124e+02, 0.,
9.3202810506563469e+02, 2.4921783008328606e+02, 0., 0., 1. ]
distortion_coefficients: !!opencv-matrix
rows: 1
cols: 5
dt: d
data: [ -2.7496876053338778e-02, 2.6835537433723529e+00,
8.8602477096542194e-04, 4.0651717606854983e-03,
-1.2148350076095600e+01 ]

A bit of theory behind camera calibration

A camera has two types of parameters which describes itss model: intrinsics and extrinsics. These parameters describes how the camera works.

The extrinsics describes where the camera is in the 3D space, and its describe by a 6D vector with translation and rotation. If you want to compute camera localization you want to compure these parameters:

    [X]
    [Y]
v = [Z]
    [α]
    [β]
    [γ]

On the other hand, the intrinsics describes how the camera maps a 3D world point on to the 2D image plane using a pinhole camera model. These internal parameters are composed by 4 or 5 elements. If you want to remove distortion (e.g. sscaling, skewing, barrel, pincushion or tangential distortion) from your images, this what you need to compute. The opencv methods output this matrix (linear distortion or camera intrisics) and a list of distortion coefficients (non-linear distortion for e.g. barrel correction).

    [  fx   0   Δx   
A =    0   fy   Δy
       0    0    1  ]    

Where:

fx, fy = focal length, it's the distance between the pinhole and the image plane. It is measured in pixel and these two values, in a true pinhole camera, are almost equivalent.

Δx, Δy = principal point offset, it's the camera's principal axis, the line perpendicular to the image plane that passes through the pinhole.

About

Repository for calibrate ssimple rgb cameras.


Languages

Language:Python 100.0%