1from kognic.io.client import KognicIOClient
2from kognic.io.model import SensorCalibration
3from kognic.io.model.calibration.camera.common import CameraMatrix, DistortionCoefficients
4from kognic.io.model.calibration.camera.pinhole_calibration import PinholeCalibration
5from kognic.io.model.calibration.common import Position, RotationQuaternion
6from kognic.io.model.calibration.common import Position, RotationQuaternion
7from kognic.io.model.calibration.lidar.lidar_calibration import LidarCalibration, LidarFieldOfView
8
9client = KognicIOClient()
10
11
12lidar_position = Position(x=0.0, y=0.0, z=0.0)
13lidar_rotation = RotationQuaternion(w=1.0, x=0.0, y=0.0, z=0.0)
14lidar_fov = LidarFieldOfView(start_angle_deg=315, stop_angle_deg=45, depth=200)
15
16lidar_calibration = LidarCalibration(position=lidar_position, rotation_quaternion=lidar_rotation, field_of_view=lidar_fov)
17
18
19
20camera_position = Position(x=0.0, y=0.0, z=0.0)
21camera_rotation = RotationQuaternion(w=0.5, x=-0.5, y=0.5, z=-0.5)
22camera_camera_matrix = CameraMatrix(fx=3450, fy=3250, cx=622, cy=400)
23camera_distortion_coefficients = DistortionCoefficients(k1=0.0, k2=0.0, p1=0.0, p2=0.0, k3=1.0)
24
25pinhole_calibration = PinholeCalibration(
26 position=camera_position,
27 rotation_quaternion=camera_rotation,
28 camera_matrix=camera_camera_matrix,
29 distortion_coefficients=camera_distortion_coefficients,
30 image_height=1080,
31 image_width=1920,
32 field_of_view=190.0,
33)
34
35sensor_calibration = SensorCalibration(
36 external_id="Create your own id here",
37 calibration={
38
39
40 "lidar": lidar_calibration,
41 "LEFT_FRONT_CAMERA": pinhole_calibration,
42 "RIGHT_FRONT_CAMERA": pinhole_calibration
43 }
44)
45created_calibration = client.calibration.create_calibration(sensor_calibration)
46print(f"Created calibration with id {created_calibration.id}")