---
title: Calibrations Overview
slug: api-guide/calibrations-overview
docTags: 
createdAt: 2024-12-17T10:06:16.522Z
---

Scenes with 2D and 3D data across various [Coordinate Systems](docId\:XqF6UaQSoFwvAVmtePdEC) need **calibration** to align sensors by location and orientation. This includes projecting 3D points onto the camera’s image plane.

::::ExpandableHeading
## Types of calibrations

All calibrations detail a sensor’s 3D position and orientation relative to the reference system. They also map 3D points to the camera’s image plane.

- For LiDAR/RADAR, there is only one type of calibration available, [ read more here](docId:4QwTBDe2OxDChRgPxSZE4).&#x20;
- For cameras, we support different types of [Standard Camera Calibrations](docId:0cLkGYTfE9bOn5xU9zeaL), where you only have to provide the intrinsic parameters of the camera.

:::hint{type="success"}
### Unsupported camera model

If your camera model is not supported, you can also provide a [Custom Camera Calibrations](docId\:F_jarCzytV6CXwZc675zK) where you provide the implementation in the form of a WebAssembly module.
:::
::::

## How to create a calibration

See this example of how to create a calibration for a LIDAR sensor and two camera sensors of type Pinhole. **For other camera types as Kannala, Fisheye etc, see** [kognic-io-examples](https://github.com/annotell/kognic-io-examples-python/tree/master/examples/calibration).

```python
from kognic.io.client import KognicIOClient
from kognic.io.model import SensorCalibration
from kognic.io.model.calibration.camera.common import CameraMatrix, DistortionCoefficients
from kognic.io.model.calibration.camera.pinhole_calibration import PinholeCalibration
from kognic.io.model.calibration.common import Position, RotationQuaternion
from kognic.io.model.calibration.common import Position, RotationQuaternion
from kognic.io.model.calibration.lidar.lidar_calibration import LidarCalibration, LidarFieldOfView

client = KognicIOClient()

# Create a sample calibration for lidar.
lidar_position = Position(x=0.0, y=0.0, z=0.0)
lidar_rotation = RotationQuaternion(w=1.0, x=0.0, y=0.0, z=0.0)
lidar_fov = LidarFieldOfView(start_angle_deg=315, stop_angle_deg=45, depth=200)

lidar_calibration = LidarCalibration(position=lidar_position, rotation_quaternion=lidar_rotation, field_of_view=lidar_fov)

# Create a sample calibration for a Pinhole camera. For other camera types visit:
# https://github.com/annotell/kognic-io-examples-python/tree/master/examples/calibration
camera_position = Position(x=0.0, y=0.0, z=0.0)
camera_rotation = RotationQuaternion(w=0.5, x=-0.5, y=0.5, z=-0.5)
camera_camera_matrix = CameraMatrix(fx=3450, fy=3250, cx=622, cy=400)
camera_distortion_coefficients = DistortionCoefficients(k1=0.0, k2=0.0, p1=0.0, p2=0.0, k3=1.0)

pinhole_calibration = PinholeCalibration(
    position=camera_position,
    rotation_quaternion=camera_rotation,
    camera_matrix=camera_camera_matrix,
    distortion_coefficients=camera_distortion_coefficients,
    image_height=1080,
    image_width=1920,
    field_of_view=190.0,
)

sensor_calibration = SensorCalibration(
  external_id="Create your own id here", # to make it easier for you to find the calibration later
  calibration={
    # The keys: "lidar", "LEFT_FRONT_CAMERA" etc, must match the
    # names of the sensors in the scenes that use this calibration
    "lidar": lidar_calibration,
    "LEFT_FRONT_CAMERA": pinhole_calibration,
    "RIGHT_FRONT_CAMERA": pinhole_calibration
  }
)
created_calibration = client.calibration.create_calibration(sensor_calibration)
print(f"Created calibration with id {created_calibration.id}")
```

:::hint{type="success"}
### Reuse calibration

Note that after a calibration has been created you can, and should, reuse the same calibration for multiple scenes if possible, see below.
:::

:::ExpandableHeading
## Get calibrations

Existing calibrations can be fetched with the retrieved id or with the provided external id. This can either be done via the client in Python or via `kognicutil`.

````text
# Fetch calibration by external id
client.calibration.get_calibrations(external_id="Collection 2020-06-16")
```
````

````text
# Fetch calibration by external id
kognicutil calibration --external-id "Collection 2020-06-16"
```
````
:::

