Skip to main content

Calibrations Overview

Scenes with 2D and 3D data across various coordinate systems need calibration to align sensors by location and orientation. This includes projecting 3D points onto the camera’s image plane.

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
  • For cameras, we support different types of standard camera calibrations, where you only have to provide the intrinsic parameters of the camera.
Unsupported camera model

If your camera model is not supported, you can also provide a custom camera calibration 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.

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}")
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.

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.

# Fetch calibration by id
client.calibration.get_calibration("e95980c4-fee2-4b91-9316-1bffbcb5a896")

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

Next steps