1from __future__ import absolute_import
2
3from datetime import datetime
4from typing import Optional
5from uuid import uuid4
6
7import kognic.io.model.scene.lidars_and_cameras as LCM
8from examples.calibration.calibration import create_sensor_calibration
9from kognic.io.client import KognicIOClient
10from kognic.io.logger import setup_logging
11from kognic.io.model import CreateSceneResponse, Image, PointCloud
12
13
14def run(client: KognicIOClient, dryrun: bool = True, **kwargs) -> Optional[CreateSceneResponse]:
15 print("Creating Lidars And Cameras Scene...")
16
17 lidar_sensor1 = "lidar"
18 cam_sensor1 = "RFC01"
19 cam_sensor2 = "RFC02"
20 metadata = {"location-lat": 27.986065, "location-long": 86.922623, "vehicle_id": "abg"}
21
22
23
24 calibration_spec = create_sensor_calibration(
25 f"Collection {datetime.now()}",
26 [lidar_sensor1],
27 [cam_sensor1, cam_sensor2],
28 )
29 created_calibration = client.calibration.create_calibration(calibration_spec)
30
31 scene = LCM.LidarsAndCameras(
32 external_id=f"lidars-and-cameras-example-{uuid4()}",
33 frame=LCM.Frame(
34 point_clouds=[
35 PointCloud(
36 filename="./examples/resources/point_cloud_RFL01.las",
37 sensor_name=lidar_sensor1,
38 )
39 ],
40 images=[
41 Image(
42 filename="./examples/resources/img_RFC01.jpg",
43 sensor_name=cam_sensor1,
44 ),
45 Image(
46 filename="./examples/resources/img_RFC02.jpg",
47 sensor_name=cam_sensor2,
48 ),
49 ],
50 ),
51 calibration_id=created_calibration.id,
52 metadata=metadata,
53 )
54
55
56 return client.lidars_and_cameras.create(scene, dryrun=dryrun, **kwargs)
57
58
59if __name__ == "__main__":
60 setup_logging(level="INFO")
61 client = KognicIOClient()
62
63
64 project = "<project-identifier>"
65
66 run(client, project=project)