# C201 Lesson 1: What Calibration Estimates

> The first lesson of the C201 camera calibration course: what a calibration of a fisheye stereo rig contains, namely intrinsics, a projection and distortion model that suits the lens, and the extrinsics between the cameras, with the direction conventions Kalibr and OpenCV use.

Page: https://egocam.ai/university/c201/lesson-1-what-calibration-estimates/

A calibration turns a camera that takes pictures into one that measures. For a stereo rig it holds two kinds of number: how each camera turns a direction into a pixel, and where each camera sits relative to the other. This lesson names every part and says which choices matter for the fisheye lenses on current head rigs. The full treatment is on [Camera Calibration](https://egocam.ai/calibration/camera-calibration/).

## Terms used in this lesson

All of these are also in the [glossary's calibration section](https://egocam.ai/reference/glossary/#calibration).

| Term | Meaning |
|---|---|
| Intrinsics | The camera model and its parameters (focal length, principal point, distortion) that map a direction in the camera's frame to a pixel |
| Focal length | In pixels, one value per image axis; it sets how much of the world each pixel covers |
| Principal point | Where the optical axis meets the sensor, in pixels; near the image centre but rarely exactly at it |
| Projection model | The formula that maps a ray's angle from the optical axis to a distance from the principal point |
| Distortion | How a real lens departs from an ideal projection; it moves image points without blurring them |
| Extrinsics | The rotation R and translation t that take points from one camera's frame to another's |
| Baseline | The distance between two cameras' optical centres, the length of t |
| Reprojection error | The distance in pixels between a detected target corner and where the calibrated model predicts it |

## Intrinsics: one camera on its own

The starting point is the pinhole model, which treats the camera as a single point that every ray passes through ([Camera Calibration](https://egocam.ai/calibration/camera-calibration/#intrinsics-the-camera-on-its-own)).

> **Diagram:** The pinhole model. A ray from a point in the world passes through the camera centre and lands on the sensor. Focal length and principal point, in pixels, are the core intrinsics.

The pinhole intrinsics are four numbers: two focal lengths and the two coordinates of the principal point. Kalibr writes them as `[fu, fv, pu, pv]` ([Kalibr File Reference](https://egocam.ai/kalibr/kalibr-file-reference/#camera_model-and-intrinsics)). On a sensor with square pixels, fu and fv should be very close.

Two rules follow from what intrinsics are:

- **They belong to one image size.** The Kalibr reference puts it plainly: the intrinsics are only valid at the `resolution` they were fitted at. A different resolution, crop or binning mode needs a new calibration ([resolution](https://egocam.ai/kalibr/kalibr-file-reference/#resolution)).
- **They belong to one lens state.** Autofocus, optical image stabilisation and electronic stabilisation all change the mapping from frame to frame, so a measuring camera locks them or does without them. If someone turns a focus ring after calibration, the calibration is gone ([Camera Calibration](https://egocam.ai/calibration/camera-calibration/#intrinsics-the-camera-on-its-own)). The reason is optical: the pinhole "focal length" is really the lens-to-sensor distance, and focusing closer moves the lens out, so the focal length in pixels grows ([Focus changes the intrinsics](https://egocam.ai/lens-physics/lens-effects-that-break-calibration/#focus-changes-the-intrinsics)).

## Projection and distortion: why fisheye lenses need their own model

Real lenses bend straight lines, most at the edges of the image. Distortion coefficients describe that bending so it can be corrected.

> **Diagram:** Real lenses bend straight lines, most at the edges of the image. The distortion coefficients describe that bending so it can be corrected.

A wide lens bends lines on purpose. Every lens maps a ray at angle θ from the optical axis to a radius r on the sensor, and lenses are designed to one of a few projection functions. The perspective (pinhole) projection, `r = f · tan(θ)`, runs to infinity at 90°, so no rectilinear lens reaches a 180° view; fisheye lenses follow other projections, such as the equidistant `r = f · θ` ([Lens Projections and Distortion](https://egocam.ai/lens-physics/projections-and-distortion/#the-classic-projections)).

> **Diagram:** How far from the image centre a ray lands (r, in units of f) for a ray arriving θ off the axis. The perspective (pinhole) curve r = f·tan θ runs to infinity at 90°, so no rectilinear lens can reach a 180° view. The fisheye projections stay finite. All five agree near the axis, which is why a narrow lens looks like a pinhole.

This is why the classic pinhole-plus-polynomial model gives out on fisheye lenses. The [double sphere paper](https://arxiv.org/abs/1807.08957v1) (Usenko, Demmel and Cremers, 2018) found that "in practice, even when distortion model is added the pinhole camera demonstrates suboptimal performance for a field-of-view greater than 120°". The models built for wide lenses, and their names in the tools this course uses:

| Model | What it assumes | Kalibr | OpenCV | mrcal |
|---|---|---|---|---|
| Pinhole + radial–tangential | a nearly rectilinear lens | `pinhole-radtan` | `calibrateCamera` | `LENSMODEL_OPENCV4/5/8/12` |
| Kannala–Brandt (equidistant) | image radius is an odd polynomial in θ | `pinhole-equi` | `cv::fisheye` | not documented |
| Extended unified (EUCM) | projection through an ellipsoid; closed-form inverse | `eucm-none` | not documented | not documented |
| Double sphere | projection through two unit spheres; closed-form inverse | `ds-none` | not documented | not documented |
| Splined | a flexible surface fitted to the lens | no | no | `LENSMODEL_SPLINED_STEREOGRAPHIC` |

The table is taken from [Calibration Tools Compared](https://egocam.ai/calibration/calibration-tools-compared/#camera-models-across-tools); the formulas are on [Lens Projections and Distortion](https://egocam.ai/lens-physics/projections-and-distortion/#from-physics-to-calibration-models).

Three findings guide the choice for a fisheye stereo rig:

- **Kannala–Brandt has a limit near 180°.** Kalibr's `pinhole-equi` and OpenCV's fisheye module apply it after a pinhole projection, so it has a singularity at 90° off axis, "which makes it unsuitable for fisheye lenses with field-of-view close to 180°" ([double sphere paper](https://arxiv.org/abs/1807.08957v1)).
- **Double sphere and EUCM fit nearly as well, and faster.** On lenses from 122° to 195°, the double sphere model had "less than 1% greater reprojection error compared to KB 8 on all sequences", and its projection was about 5.6 times faster ([Calibrating a Stereo or Multi-Camera Rig](https://egocam.ai/calibration/stereo-and-multi-camera-calibration/#choosing-a-camera-model-for-each-camera)).
- **Use the model your pipeline consumes.** A SLAM system or dataset format that expects Kannala–Brandt parameters gains nothing from a better fit in a model it cannot read ([Lens Projections and Distortion](https://egocam.ai/lens-physics/projections-and-distortion/#which-model-for-which-lens)).

One more check applies to any model: real radial distortion is monotonic. OpenCV's documentation treats a non-monotonic fit as "a calibration failure", and one way it happens is a target that never reached the image corners ([Lens Projections and Distortion](https://egocam.ai/lens-physics/projections-and-distortion/#real-radial-distortion-is-monotonic)).

## Extrinsics: where the second camera sits

Extrinsics are the rotation R and translation t between two cameras' frames. On a rigid head unit they are fixed by the mechanics; a wrist camera moves relative to the head and is tracked per frame instead ([Camera Calibration](https://egocam.ai/calibration/camera-calibration/#extrinsics-where-each-sensor-sits)).

> **Diagram:** Extrinsics are the rotation R and translation t between sensors. On a rigid head unit they are fixed and calibrated once; a wrist camera moves relative to the head, so its pose is tracked frame by frame instead.

For a stereo pair, the extrinsics set the depth. Stereo depth is `z = f·b / d`, so a baseline that is 1% wrong makes every depth 1% wrong ([Calibrating a Stereo or Multi-Camera Rig](https://egocam.ai/calibration/stereo-and-multi-camera-calibration/#checking-a-multi-camera-calibration)).

The direction of a transform is the classic mistake, and nothing warns you about it:

- **Kalibr** writes every transform as `T_a_b`, which takes a point in frame b and returns it in frame a. For cam1, `T_cn_cnm1` is `T_c1_c0`, which in the Kalibr wiki's words "takes cam0 to cam1 coordinates". Its translation is in metres, and its length is the baseline ([How Kalibr names transforms](https://egocam.ai/kalibr/kalibr-file-reference/#how-kalibr-names-transforms)).
- **OpenCV's** `stereoCalibrate` returns R and T where "this matrix brings points given in the first camera's coordinate system to points in the second camera's coordinate system" ([OpenCV calib3d reference](https://docs.opencv.org/4.x/d9/d0c/group__calib3d.html)).

> **Diagram:** How Kalibr names its transforms. T_a_b takes a point given in frame b and returns it in frame a. Each camera block in camchain-imucam.yaml stores T_cam_imu (IMU to that camera), and every camera after cam0 stores T_cn_cnm1 (the previous camera to this one, so cam1 holds T_c1_c0).

The translation of `T_a_b` is the origin of frame b seen from frame a. Comparing its length with a ruler is the quickest check that you have read it the right way round.

## What the solver does with all this

A calibration solver shows the cameras a target of known geometry, predicts where each corner should land given the current parameters, and adjusts every parameter until the predicted corners land as close as possible to the detected ones. That gap is the reprojection error, the number every tool reports ([Camera Calibration](https://egocam.ai/calibration/camera-calibration/#how-calibration-works)). Lessons 2 to 4 cover the views it needs, the tools that solve it and why a low error alone proves little.

## Self-check

1. Your team switches the stereo cameras from full resolution to a 2 × 2 binned mode. Can they keep the calibration?
2. Your lenses have a field of view close to 180°. Which Kalibr models does the field guide point you to, and which one does it warn against?
3. In a Kalibr camchain, what does `T_cn_cnm1` under cam1 map from and to, and what is the length of its translation?
4. Why might a team pick Kannala–Brandt even though double sphere fits as well and projects faster?

### Answers

1. No. Intrinsics are only valid at the resolution they were fitted at; a new binning mode needs a new calibration.
2. Models defined on the 3D ray: double sphere (`ds-none`), EUCM (`eucm-none`) or unified with radtan (`omni-radtan`). Kalibr's `pinhole-equi` has a singularity at 90° off axis that makes it unsuitable near 180°.
3. It maps cam0 coordinates into cam1 coordinates (`T_c1_c0`). The length of its translation is the baseline, in metres.
4. Because the rest of the pipeline reads Kannala–Brandt. A model the SLAM system or dataset format cannot consume is no use, however well it fits.

## Sources

- Field guide: [Camera Calibration](https://egocam.ai/calibration/camera-calibration/), [Lens Projections and Distortion](https://egocam.ai/lens-physics/projections-and-distortion/), [Calibration Tools Compared](https://egocam.ai/calibration/calibration-tools-compared/), [Calibrating a Stereo or Multi-Camera Rig](https://egocam.ai/calibration/stereo-and-multi-camera-calibration/), [Kalibr File Reference](https://egocam.ai/kalibr/kalibr-file-reference/), [glossary](https://egocam.ai/reference/glossary/#calibration).
- Usenko, V., Demmel, N. and Cremers, D. (2018). [The double sphere camera model](https://arxiv.org/abs/1807.08957v1). *International Conference on 3D Vision (3DV)*.
- OpenCV [calib3d module reference](https://docs.opencv.org/4.x/d9/d0c/group__calib3d.html) (`stereoCalibrate`, distortion models).
- Kalibr wiki, ETH Zurich ASL: [YAML formats](https://github.com/ethz-asl/kalibr/wiki/Yaml-formats).
