# Calibration Modes and Models

* The calibration establishes the relationship between real-world point coordinates and image pixels.
  * The real-world coordinates are defined with respect to a real-world reference plane.
  * The real-world coordinates are expressed as 2D points where the Z coordinates is by convention equal to 0 on the reference plane.
* The object [`ECameraCalibration`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html) represents the transformation from the real-world coordinates to the image coordinates (also called the sensor coordinates).
  * Use [`ECameraCalibration::WorldToSensor`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#ac82dc3df0c401029ee79835a4764d0fd) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#a98784433088949ce3d4cc499e106e96a) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a8538909528561fb9a86a91440c068fa2) to transform from the real-world coordinates to the image coordinates.
  * Use [`ECameraCalibration::SensorToWorld`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#ae20695d29632c97924bd234a20422692) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#a4ef7fc6f02d42e8f23466e5fa5a976a6) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a15daf35333e845f8175eff73cbf9afea) for the reverse transformation.
* This object also has a method to:
  * Set or compute the calibration: See [Computing the Calibration Model](computing_the_calibration_model.html.md).
  * Perform the unwarping: See [Unwarping an Image](unwarping_an_image.html.md).
* The property [`ECameraCalibration::GetCalibrationModes`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#ae881b05e975504501973c941347bf9fd) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#a904b61e9fef65807599da0a5656ad65f) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a6f02c2ea4531e4e43e6c1b822e91e6ba) is a combination of the flags [`ECalibrationMode`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html) that indicates the model used for the calibration.
* The [`ECameraCalibration`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html) has 4 categories of models:
  *  ***No calibration at all*** where the real-world coordinates of a point are identical to the image coordinates of this point ([`ECalibrationMode_Raw`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html)).
  * The  ***field-of-view calibration*** model where the calibration mode is the combination of the modes [`ECalibrationMode_Scaled`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html), [`ECalibrationMode_Anisotropic`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html), [`ECalibrationMode_Skewed`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html), [`ECalibrationMode_Tilted`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html) and [`ECalibrationMode_Radial`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html).
  * The  ***advanced calibration*** model that is equivalent to the complete field-of-view model with more distortion coefficients ([`ECalibrationMode_Advanced`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html)).
  * The  ***empirical*** models that are based on a quadratic model (mode [`ECalibrationMode_Quadratic`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html)) or a bilinear model ([`ECalibrationMode_Bilinear`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html)).
* All calibration models have:
  * A center ([`ECameraCalibration::GetCenter`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#a31a71dafd41430a7079e714659b3461c) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#a39eb5f60ad5b16c2e8e2cd974868e3ca) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#aa8717eddf0735b07d468afb0bb1641ae)) that represents the pixel coordinates of the real world point (0, 0).
  * A sensor width ([`ECameraCalibration::GetSensorWidth`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#a9482fb93b021500f381cf2851b3d947e) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#a02d3aaeaedcf117f655050de57805d70) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#adfc36b2a7bf6f12eb963d03a5fa246ed)) and a sensor height ([`ECameraCalibration::GetSensorHeight`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#ac84710d83286ba371d8dbf2d5802c617) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#a14675f468099c3d0983c386f72574c1f) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a88e782afe099181e18a2fbbba482f38c)) that correspond to the image size.

#### NOTE
When computing the calibration, pass the mode or the combination of modes that you want to test. The method selects the model that has the best precision on the calibration image.<br />
\\\\
See [Computing the Calibration Model](computing_the_calibration_model.html.md).

## The field-of-view model

* The field-of-view model can combine various modes to express the transformation from the real-world coordinates to the sensor coordinates.
* To manually set the field-of-view model, use [`ECameraCalibration::SetSensor`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#a856ab5441f450cbff0fc8456f4a19b36) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#ab01574a3fbfa7b03b0f5ed78b4781851) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#ae0dd3480e51892ea2499b2239991eedd) or [`ECameraCalibration::SetSensorUsingResolution`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#a7a5b2306a251ba44570d8f41a0e71370) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#a3bff644675616db81f2f002df55c3a5b) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a9f942cdab28bd3d9fdc19218dad3529d). These methods have different representations of the scaling.

### Scaling

* You can express the scaling in 2 ways:
  * Using the field-of-view width and height ([`ECameraCalibration::GetFieldWidth`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#ac6f468f6c021b6396f3d9dd21a762741) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#ab40ad8602d05725dbaa15f4d34ae8f5e) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#af5b3b224982d9f4cd12dd8f11898e481) and [`ECameraCalibration::GetFieldHeight`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#aecc807c4f22a374ee3645bd84936266a) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#aa47f9e4785906b952dc84034b9518f9b) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a0b862ba08141bb866c3104cb42d6a0d7)): the size of the real-world reference plane if its limits correspond to the image edges (expressed in metric units).
  * Using the X and Y resolution ([`ECameraCalibration::GetXResolution`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#a7a5e5a6291309e26f1059b3f279cebed) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#aa43b201dd8553ef6065102ba9e6c0830) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a39c677fbcfdcd02ef5cc43dc6d676e31) and [`ECameraCalibration::GetYResolution`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#a0e68ccac09fc82f17dfaee49d9004f97) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#afc5772be6f7ef9fe66de8e4440d4e353) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#ad702e7fd77ad45c87f1f5dc394413d42)): the number of pixels corresponding to a metric unit (in pixels/metric unit)
* The field-of-view width ($w_{fov}$) and height ($h_{fov}$) and the X and Y resolution ($R_X$ and $R_Y$) are linked as follows:

$w_{sensor} = w_{fov} * R_X$

$h_{sensor} = h_{fov} * R_Y$

* The pixel width ($w_{pixel}$) and height ($h_{pixel}$) can also be expressed using the field-of-view width and height or the X and Y resolution:

$w_{pixel} = \frac{w_{fov}}{w_{sensor}} = \frac{1}{R_X}$

$h_{pixel} = \frac{h_{fov}}{h_{sensor}} = \frac{1}{R_Y}$

* By default, the model assumes an isotropic scaling and the X and Y resolution are the same.
  * When the model is anisotropic ([`ECalibrationMode_Anisotropic`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html)), the anisotropy is also represented by the ratio of the X and Y resolution ([`ECameraCalibration::GetRatio`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#ab16c48e0b29eda198828366cef2a3a15) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#afe92faa1a15daf2b6b2e7311e5d6a2c0) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a5dee6a02cbc780c16b8e6414882b3c52)).

### Skew

The skew angle ([`ECameraCalibration::GetAngle`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#ac881afc8558d7b0d161868403db28c71) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#a6f3fef17a8b47b99beff9b8f8d6696f3) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a480ccf0c8099e4e7bbd9434d7880ac4b)) is the angle formed by the X axis of the real-world reference frame with the horizontal image edge.

![image](assets/images/easygauge/calibrationangle.webp)

### Tilt

The X and Y tilt ([`ECameraCalibration::GetTiltXAngle`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#a89b6dd8fce112d447c26f27059cfbf8d) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#aa44c4156f33f0a328de154325c30afe2) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a90402ee6da58bd2a6a36e9bc2678396b) and [`ECameraCalibration::GetTiltYAngle`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#a7978964565aa41d58fc4a02b7469bacd) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#a12869bb424eeab74c8f284f0a589b7c2) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a36012de87950dd588706e416e50e9078)) happens when the reference frame is not perpendicular to the optical axis. They correspond to the required rotations around the real world X and Y axis that would bring the Z axis parallel to the optical axis.

![](assets/images/easygauge/calibrationtiltxangle.webp)![](assets/images/easygauge/calibrationtiltyangle.webp)

### Perspective strength

The perspective strength ([`ECameraCalibration::GetPerspectiveStrength`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#a07f9302af75e1d43d9bb084d238fd1c9) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#ab65eada7f18e49194e9bd14243088641) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a967c080211b25fbbf193e9119bb6d4e4)) gives a relative measure of the perspective effect.

* The shorter the focal length, the larger the value.
* The closer the reference plane is to the camera, the larger the value.
  ![Weak perspective](assets/images/easygauge/calibrationperspectiveweak.webp)![Strong perspective](assets/images/easygauge/calibrationperspectivestrong.webp)

### Distortion strength

The distortion strength ([`ECameraCalibration::GetDistortionStrength`](../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#a54e42e3476cd2151fcf8b69d6d5b1903) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#af89d512e09d38af17065d1640998e7d2) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECameraCalibration.html#aa8eb5d77e68b2b93cd8a147e0872b293)) gives a relative measure of radial distortion in the image corners, that is the ratio of image diagonal length with and without distortion.

![Positive distortion](assets/images/easygauge/calibrationdistortionpositive.webp)![Negative distortion](assets/images/easygauge/calibrationdistortionnegative.webp)

## Effects of the calibration modes

The following table shows the effects of the projection of a real-world rectangle in an image according to different calibration mode.

| Modes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | Description                                                                                         | Visualization                                                                  |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
| [`ECalibrationMode_Raw`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html)                                                                                                                                                                                                                                                                                                    | No calibration                                                                                      | ![image](assets/images/easygauge/worldtosensortransformuncalibrated.png)       |
| [`ECalibrationMode_Anisotropic`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html)                                                                                                                                                                                                                                                                                            | The physical pixels are not squared.<br/><br/>The image can appear stretched                        | ![image](assets/images/easygauge/worldtosensortransformscalednonsquare.png)    |
| [`ECalibrationMode_Skewed`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html)<br/>[`ECalibrationMode_Scaled`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html) | Affine isotropic transformation (rotation, translation and scaling)                                 | ![image](assets/images/easygauge/worldtosensortransformscaledskewedsquare.png) |
| [`ECalibrationMode_Tilted`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html)                                                                                                                                                                                                                                                                                                 | Further away objects appears smaller.<br/><br/>Lines remains straight but angles are not preserved. | ![image](assets/images/easygauge/worldtosensortransformperspective.png)        |
| [`ECalibrationMode_Radial`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html)                                                                                                                                                                                                                                                                                                 | Barrel distortion                                                                                   | ![image](assets/images/easygauge/worldtosensortransformoptical.png)            |

## The advanced model

The advanced model ([`ECalibrationMode_Advanced`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html)) is equivalent to a field-of-view calibration model with:

* All modes activated.
* 5 distortion coefficients: $k_1$, $k_2$, $k_3$, $p_1$ and $p_2$.

## The empirical models

The empirical models are either based on a quadratic ([`ECalibrationMode_Quadratic`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html)) or a bilinear ([`ECalibrationMode_Bilinear`](../../../doxygen_cpp/namespaceeVision.html#aa4f09c74296350db3ffce101d476f05a) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aadc222f93604cb16a11491a0bf6e52ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ECalibrationMode.html)) model.

* These models do not expose their parameters.
