# Model n Calibration

## General camera model

There are 3 Coordinate Frames

* World {O}, Camera frame {C}, Image plane{Im}

The transformation between coordinate frames are

* Euclidean: {O} -> {C}, Mext : the camera extrinsic matrix
* Perspective Projection: {C}-> {Im}, Mint : the camera intrinsic matrix

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-5112c4e2ffbc21c65c4e7a1f1c85bc1c4242253b%2Fimage%20\(290\).png?alt=media)

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-b3da88a225fcb30f323f7a7510787e8dbbef6f9d%2Fimage%20\(293\).png?alt=media)

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-43c6f45c81c412e4e15251e7fc9284057f8330cd%2Fimage%20\(288\).png?alt=media)

> x: Image Coordinates: (u,v,1)
>
> K: Intrinsic Matrix (3x3)
>
> R: Rotation (3x3)
>
> t: Translation (3x1)
>
> X: World Coordinates: (X,Y,Z,1)

### Extrinsic Matrix

Finding the camera external matrix of Mext, which is the transformation from {O} to {C}: Xc=\[R | T] Xo

> Here, R, T are from frame {C} to {O}. Depending on the notation, it can be the pose of {O} w.r.t {C}

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-23fc54fb1dedd16330bb615e432cdf4125a39ad0%2Fimage%20\(285\).png?alt=media)

### Intrinsic Matrix

#### Perspective projection in {C}: From {C} (3D) to {C} (2D)

> _p_ is NOT in pixel unit. It is in (mm) at distance 'f' from the {C} center point.

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-bc7b6a5d23793bfd35c65da8c9f055a32e18dac3%2Fimage%20\(294\).png?alt=media)

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-b0e320b571505bd15603519630c9bc4af373274c%2Fimage%20\(281\).png?alt=media)

The relationship between P and _p_ are based on the similar triangle such as

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-42ce7ba5ae40c3ca687a2e67b3a9481ab93d2098%2Fimage%20\(283\).png?alt=media)

#### Unit Conversion from {C} 2D (mm) to {Im} 2D

On the same image plane, the unit is changed from (mm) to (px). This depends on the mm-px scale unit, which is the image sensor pixel size.

> Here, we assume that there is NO skew and lens distortion

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-9ec9f587d2d5557852dc22c086e16ee0686f31ea%2Fimage%20\(282\).png?alt=media)

#### Intrinsic camera matrix, Mint

Putting the above two equations, the matrix Mint is the transformation between the camera frame {C} 3D(mm) and the image plane frame {Im} 2D(px)

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-c9c86d3489079065c5c4268f94f2856ce5b45118%2Fimage%20\(284\).png?alt=media)

> The scale factor cZ is not known from one frame of image. It is the actual distance of the object from the projection center.

Thus, from the image acquisition, we express the object position in px without knowing the exact scale as

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-1234e2d8a9f234c4e2169990854df6a5bc66fd6a%2Fimage%20\(291\).png?alt=media)

## Camera Calibration

It is determining (1) Extrinsic Matrix (2) Intrinsic Matrix including lens distortion

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-a3226078840cdff22b2094f48adb578bb2d55d20%2Fimage%20\(287\).png?alt=media)

* Intrinsic Calibration
  * Lens distortion
  * Camera internal parameters
* Extrinsic Calibration
  * 6-DOF relative pose between the camera frame (3-D) and the world coordinate frame (3-D)
  * R, T are from {O} to {C}

### Intrinsic Calibration

Camera parameters

* focal length (mm)
* image center (px)
* effective pixel size (px/mm)

Lens Distortion

* Chromatic aberration
  * Index of refraction for glass varies as a function of wavelength.
  * Different color rays have different refraction
* Spherical aberration
  * Real lenses are not thin and suffers from geometric aberration
* Radial Distortion
  * Distortion at the periphery of the image

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-f2b82ab9363b08c0ce643ce7bdf04099e56b3e7e%2Fimage%20\(286\).png?alt=media)

Xp: points’ location when lens is perfectly undistorted

Xd: points’ location when lens is distorted

Use a set of many points to find the distortion parameters such as corner points of a chess board.

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-7cb6d79a4af5135524e9bd7e2c0855fc77f2aeb0%2Fimage%20\(280\).png?alt=media)

### Zhang calibration method

Zhang, Zhengyou. "A flexible new technique for camera calibration." IEEE Transactions on pattern analysis and machine intelligence 22.11 (2000): 1330-1334.

Read here for detailed explanation

{% embed url="http://staff.fh-hagenberg.at/burger/publications/reports/2016Calibration/Burger-CameraCalibration-20160516.pdf" %}

## Appendix

#### Q What are affine, projection, projective, perspective, homography?

* Projection is mapping 3D to 2D
  * orthography, perspective(pinhole camera) and more
*   Transformation: 2D-2D or 3D-3D

    * Euclidean, affine, similarity, projective
    * Projective Transformation is also known as **perspective transformation or homography**

    \*\*\*\*

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-4590c01a2c47a3d91a7a3a2e53ab093bba1dc69b%2Fimage%20\(301\).png?alt=media)

#### Transformation: 2D-2D or 3D-3D (in the same dimension)

* projective: parallel lines converge to vanishing point

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-6f5f952c7a82fa971e609bc6786a7bfbf473e265%2Fimage%20\(297\).png?alt=media)

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-99aba9f2640e8fea842e9e0f8b7ec2664986f448%2Fimage%20\(298\).png?alt=media)

Transformation Types

* Euclidean: preserves lengths and angles(isometry)
* Similarity: isotropic scaling preserves angle, shape, ratios of length, areas, angles
* Affine: non-singular transformation preserves parallelism A: n by n non-singular matrix (3x3 for 3D point)
* Projective: linear transformation on homogeneous n-vector (3D point: 4 x1 vector)
  * Perspective projection(3D-2D) is a subclass of projective transformation
  * P: non-singular nxn (4x4 for 3D point)

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-69d110b25fd74a852d5ab47c8cf99d66a00850c0%2Fimage%20\(295\).png?alt=media)

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-4ca99fe5829b6bb9901e715e43b0bdca69ca711d%2Fimage%20\(303\).png?alt=media)

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-2de7f0b494dc68350965b2e26e01b7e5d2a9d6f2%2Fimage%20\(296\).png?alt=media)

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-aeca5a73ecd8ffdf0f2b5fdd062ebeece5b97195%2Fimage%20\(299\).png?alt=media)

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-040b71635dba14086ff88af0e00285042ba2d67b%2Fimage%20\(302\).png?alt=media)
