# Dynamic Calibration Specification

`DynamicCalibration` re-estimates the rotation between the left and right cameras of one stereo device while it runs. It does not
change the baseline length or the lens parameters (intrinsics). This page covers the measured accuracy and what that accuracy
means for depth. For node configuration and code examples, see the [DynamicCalibration node
guide](https://docs.luxonis.com/software-v3/depthai/depthai-components/host_nodes/dynamic_calibration.md).

### Up to 3 image pairs

90 % of sessions complete calibration within 3 image pairs.

### < 0.022° yaw error

For 90 % of sessions. At 2 m with a 7.5 cm baseline, that is about 1 % depth error.

### 98.9 % completion

Across a large set of recordings from multiple OAK models.

## Setup requirements

The accuracy figures apply when the scene meets the [scenery
guidelines](https://docs.luxonis.com/software-v3/depthai/depthai-components/host_nodes/dynamic_calibration.md#Scenery%20guidelines):
textured objects at varied distances, visible in both cameras, with the device and scene still during capture. All tested devices
have a 7.5 cm baseline.

## How the results were measured

All results were measured with the calibration library in DepthAI 3.12.2 and the node's default settings, on a large set of
recordings from multiple OAK models.

### What the errors measure

![Left: a stereo pair seen from above, with the right camera turned sideways by a small yaw error. Right: rectified left and right images where the same feature lands on different rows.](https://docs.luxonis.com/static/images/software/depthai/nodes/dynamic-calibration/rotation-errors.svg)

 * Total rotation error is the angle between the estimated and the true rotation of the right camera relative to the left, in
   degrees.
 * Yaw error is the part of that rotation around the vertical axis. Yaw shifts disparity, so it scales depth: it is the error that
   matters most for depth accuracy.
 * Vertical misalignment of rectified rows is how far, in pixels, the same point lands on different rows in the rectified left and
   right images. It comes from tilt (pitch and roll) errors. Stereo matching searches along rows, so large misalignment reduces
   depth fill rate.

> **Percentiles are not maximum errors**
> An entry such as "0.022° at the 90th percentile" means nine out of ten sessions had a smaller error. It is not a maximum error for every session.

## Results

### Convergence

98.9 % of sessions completed calibration: 61 % on the first image pair and 90 % within 3.

### Rotation error after calibration

| Metric | Median | 90th percentile |
| --- | --- | --- |
| Total rotation error | 0.008° | 0.04° |
| Yaw error | 0.005° | 0.022° |
| Vertical misalignment of rectified rows | 0.03 px | 0.28 px |

Row misalignment stays well under one pixel. Starting errors up to 1° do not change the result.

### What the yaw error means for depth

A yaw error adds a depth error that grows with distance and shrinks with baseline:

$$
\text{depth error [\%]} \approx 1.75 \cdot \frac{\text{distance [m]} \cdot \text{yaw error [°]}}{\text{baseline [m]}}
$$

The chart shows this error for a 7.5 cm baseline: the green line for the median yaw error (0.005°) and the blue line for the 90th
percentile (0.022°).

| Distance | Median yaw error | 90th percentile yaw error |
| --- | --- | --- |
| 1 m | 0.12 % | 0.51 % |
| 2 m | 0.23 % | 1.02 % |
| 4 m | 0.47 % | 2.05 % |

This error adds to the stereo matching error. For the overall depth error of each device, see [Depth
accuracy](https://docs.luxonis.com/hardware/platform/depth/depth-accuracy.md).

### With AutoCalibration checks

[AutoCalibration](https://docs.luxonis.com/software-v3/depthai/depthai-components/host_nodes/auto_calibration.md) does not apply
every result. It applies a result only when both checks pass, so a weak result never replaces a good calibration:

![A calibration result must pass two checks to be applied: dataConfidence above 0.85 (0.65 for wide lenses) and calibrationConfidence above 0.9 on 5 new image pairs. 95 % of sessions passed at the first attempt. A result that fails either check is rejected and the current calibration is kept.](https://docs.luxonis.com/static/images/software/depthai/nodes/dynamic-calibration/autocalibration-checks.svg)

Rejecting the weaker results lowers the 90th percentile yaw error from 0.022° to 0.018°. Even at the 95th percentile, the yaw
error is 0.025°, about 1.2 % depth error at 2 m.

### Repeatability

Repeated runs on the same recording differ by about 0.02° in yaw. A factory calibration deliberately turned by 0.2° to 2° gave the
same result as the original one.

### Calibration quality check

The quality check tests the calibration stored on the device without replacing it. It flags the calibration for recalibration when
`calibrationConfidence` drops below 0.9.

| Stored calibration off by | Depth error at 2 m | Flagged by the check |
| --- | --- | --- |
| 0.2° | ≈ 9 % | 99 % |
| 0.5° or more | ≥ 23 % | 100 % |

Smaller errors were not tested. Depth errors assume the whole calibration error is in yaw.

## When to recalibrate

Temperature changes, shocks, vibration and long-term drift slowly turn the cameras relative to each other. A rotation that small
is invisible in the images, but it shows up in depth:

 * Depth scale is off, and the error grows with distance. This is yaw error. A stored calibration off by 0.2° already gives about
   9 % depth error at 2 m.
 * Depth has more holes and lower fill rate. This is tilt error: matching points no longer land on the same rectified row.

| Situation | What to do |
| --- | --- |
| Stable mount and temperature | Keep the default [ON_START](https://docs.luxonis.com/software-v3/depthai/depthai-components/host_nodes/auto_calibration.md#ON_START%20procedure) mode (default from DepthAI 3.6). It recalibrates each time the pipeline starts. |
| Large temperature swings or constant vibration | Use [CONTINUOUS](https://docs.luxonis.com/software-v3/depthai/depthai-components/host_nodes/auto_calibration.md#CONTINUOUS%20procedure) mode. It keeps recalibrating during runtime, at the cost of extra processing. |
| After a knock, drop or re-mounting | Recalibrate before relying on depth: restart the pipeline in ON_START mode or trigger a calibration in the `DynamicCalibration` node. |
| Long-running deployment | Run the [calibration quality check](#Calibration%20quality%20check) periodically and recalibrate when it flags the stored calibration. |
| Lenses changed, a camera module replaced or moved (FFC) | Dynamic Calibration cannot help: it does not update intrinsics or the baseline. Do a [full calibration](https://docs.luxonis.com/hardware/platform/depth/manual-calibration.md). |
| Device reports that its calibration is too old for Dynamic Calibration | Dynamic Calibration is not supported on this device. Do a full calibration. |

If a recalibration makes depth worse, [restore the factory
calibration](https://docs.luxonis.com/software-v3/depthai/depthai-components/host_nodes/dynamic_calibration.md#Restore%20factory%20calibration).
Dynamic Calibration writes to the user calibration and leaves the factory calibration untouched.

### Need assistance?

Head over to [Discussion Forum](https://discuss.luxonis.com/) for technical support or any other questions you might have.
