Upload your first scene
3 min
when uploading raw data to the kognic platform, you need to do so in the form of a scene a scene is a collection of data from different sources, such as images, point clouds, and other sensor data this guide will walk you through the process of uploading your first scene, either in 2d (camera only) or 3d (camera and lidar/radar) prerequisites you have successfully followed the quickstart docid\ b6im5u kiwn9ukybzjx6d guide and have the kognic io library installed for users with access to multiple workspaces you need to specify a workspace to upload data too docid\ xmgm2k teox9jtn otqbm code examples uploading a 2d scene to upload a 2d scene, you need to have the raw images available on your local machine (or create a callback docid\ yunpnpwuhzlgg9wb9qnk8 for remote data) it is a two step process build the scene object in python upload the scene object to the kognic platform below follows examples for a few different cases from kognic io client import kognicioclient from kognic io model scene cameras import cameras, frame from kognic io model scene resources import image \# 1 build scene object scene = cameras( external id="my first scene", frame=frame(images=\[image(filename="path/to/image jpg")]) ) \# 2 upload scene client = kognicioclient() scene uuid = client cameras create(scene) scene uuid print("scene uploaded, got uuid ", scene uuid)from kognic io client import kognicioclient from kognic io model scene cameras import cameras, frame from kognic io model scene resources import image \# 1 build scene object scene = cameras( external id="my first scene", frame=frame( images=\[ \# sensor names must be unique image(sensor name = "cam1", filename="path/to/image1 jpg"), image(sensor name = "cam2", filename="path/to/image2 jpg") ], ) ) \# 2 upload scene client = kognicioclient() scene uuid = client cameras create(scene) scene uuid print("scene uploaded, got uuid ", scene uuid)from kognic io client import kognicioclient from kognic io model scene cameras sequence import camerassequence, frame from kognic io model scene resources import image \# 1 build scene object scene = camerassequence( external id="my first scene", frames=\[ \# relative timestamps must be unique and strictly increasing frame( relative timestamp=0, frame id="1", images=\[image(filename="path/to/image1 jpg")], ), frame( relative timestamp=100, frame id="2", images=\[image(filename="path/to/image2 jpg")], ), frame( relative timestamp=200, frame id="3", images=\[image(filename="path/to/image3 jpg")], ), ] ) \# 2 upload scene client = kognicioclient() scene uuid = client cameras sequence create(scene) scene uuid print("scene uploaded, got uuid ", scene uuid) uploading a 2d/3d scene to upload a 2d/3d scene, you need to have the raw images and point clouds available on your local machine (or create a callback docid\ yunpnpwuhzlgg9wb9qnk8 for remote data) in addition you need to have calibration data available it is a three step process create a calibration docid 4mfc9atwcxupflne7v1iz build the scene object in python, referencing the calibration from the previous step upload the scene object to the kognic platform below follows examples for a few different cases from kognic io client import kognicioclient from kognic io model calibration import sensorcalibration, pinholecalibration, lidarcalibration from kognic io model scene lidars and cameras import lidarsandcameras, frame from kognic io model scene resources import image, pointcloud client = kognicioclient() \# 1 create calibration (see calibration section for more details) sensor calibration = sensorcalibration( external id = "my first calibration", calibration = { "cam" pinholecalibration( ), "lidar" lidarcalibration( ) } ) created calibration = client calibration create calibration(sensor calibration) \# 2 build scene object scene = lidarsandcameras( external id=f"my first scene", calibration id = created calibration id, frame=frame( images=\[image(sensor name = "cam", filename="path/to/image jpg")], point clouds=\[pointcloud(sensor name = "lidar", filename="path/to/pointcloud pcd")] ) ) \# 3 upload scene scene uuid = client lidars and cameras create(scene) scene uuid print("scene uploaded, got uuid ", scene uuid)from kognic io client import kognicioclient from kognic io model calibration import sensorcalibration, pinholecalibration, lidarcalibration from kognic io model scene lidars and cameras import lidarsandcameras, frame from kognic io model scene resources import image, pointcloud client = kognicioclient() \# 1 create calibration (see calibration section for more details) sensor calibration = sensorcalibration( external id = "my first calibration", calibration = { "cam1" pinholecalibration( ), "cam2" pinholecalibration( ), "lidar" lidarcalibration( ) } ) created calibration = client calibration create calibration(sensor calibration) \# 2 build scene object scene = lidarsandcameras( external id="my first scene", calibration id = created calibration id, frame=frame( images=\[ image(sensor name = "cam1", filename="path/to/image1 jpg"), image(sensor name = "cam2", filename="path/to/image2 jpg"), ], point clouds=\[pointcloud(sensor name = "lidar", filename="path/to/pointcloud pcd")] ) ) \# 3 upload scene client = kognicioclient() scene uuid = client lidars and cameras create(scene) scene uuid print("scene uploaded, got uuid ", scene uuid)from kognic io client import kognicioclient from kognic io model calibration import sensorcalibration, pinholecalibration, lidarcalibration from kognic io model scene lidars and cameras sequence import lidarsandcamerassequence, frame from kognic io model scene resources import image, pointcloud client = kognicioclient() \# 1 create calibration (see calibration section for more details) calibration = { "cam" pinholecalibration( ), "lidar" lidarcalibration( ) } sensor calibration = sensorcalibration( external id = "my first calibration", calibration = { "cam" pinholecalibration( ), "lidar" lidarcalibration( ) } ) created calibration = client calibration create calibration(sensor calibration) \# 2 build scene object scene = lidarsandcamerassequence( external id="my first scene", calibration id = created calibration id, frames=\[ \# relative timestamps must be unique and strictly increasing frame( relative timestamp=0, frame id="1", images=\[image(sensor name = "cam", filename="path/to/image1 jpg")], point clouds=\[pointcloud(sensor name = "lidar", filename="path/to/pointcloud1 pcd")] ), frame( relative timestamp=100, frame id="2", images=\[image(sensor name = "cam", filename="path/to/image2 jpg")], point clouds=\[pointcloud(sensor name = "lidar", filename="path/to/pointcloud2 pcd")] ), frame( relative timestamp=200, frame id="3", images=\[image(sensor name = "cam", filename="path/to/image3 jpg")], point clouds=\[pointcloud(sensor name = "lidar", filename="path/to/pointcloud3 pcd")] ), ] ) \# 3 upload scene scene uuid = client lidars and cameras sequence create(scene) scene uuid print("scene uploaded, got uuid ", scene uuid) multiple point clouds is also supported, but not shown in the examples above since that requires a bit more data see the motion compensation docid\ rhbsetwlntflfo6fmd 1e section for more details uploading using zod data we have exemplar code and a tutorial for uploading scenes using zenseact open dataset (zod) https //zod zenseact com/ data, including 2d, 3d, and aggregated 3d scenes check out the guide document and exemplar code here! docid\ cz51x 3 lqonbcpftohmq if you have the zod data downloaded, and have kognic api credentials, the examples will run out of the box to create functional scenes! creating scenes from files in a bucket supported in kognic io>=2 5 1 to use this feature need to have configured a data integration docid\ l93 pnieahqpk 6j ouef if you have your data in a kognic supported format in a bucket, and have set up a data integration for the bucket, you can create your scene like this, providing paths to files in your bucket instead of downloading and uploading data through the script this example is a full 2d+3d scene, but can be reduced to a 2d only scene by removing pointclouds, imu data and ego vehicle poses doing it this way uses a newer scene model which does not require you to specify the scene type; it is inferred from the presence of images and pointclouds, and scenes created this way are always 'sequence' type scenes a code example and more information can be found at scene examples docid\ hxbekmqtar nccl7pmgxr imu data uploaded this way is expected as json in the following format \[ { "postion" { "x" 0 0, "y" 0 0, "z" 0 0 }, "rotationquaternion" { "w" 0 0, "x" 0 0, "y" 0 0, "z" 0 0 } "timestamp" \<unix timestamp in nano seconds> }, ]
