Scene examples
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.
In kognic-io 2.5.0 we released a new scene model that infers the scene type from the sensor data; if there are no pointclouds, a camera-only sequence is created.
Scenes created via this new model and its associated API will always be sequences, meaning they cannot be added to Requests that require non-sequence inputs. Over time, we expect to standardize on sequences everywhere, so this should become less of a concern over time.
There is no need to specify that a scene is aggregated with the new model, and we no longer support creation of so-called "pre-aggregated" scenes which contained a 'fat' pointcloud in the first frame, and nothing in the rest. See Aggregated Lidars and Cameras Sequence for details.
You can read more detailed information about this model here.
Create scene from local files
This guide will walk you through the process of uploading a scene where the sources are located on your computer.
Prerequisites
You have successfully followed the Quickstart 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.
To upload scenes using cloud resources you need the following:
- kognic-io >= 2.5.1
- a calibration for your scene
- data locally in a file format that kognic supports
Examples
Note that postpone_external_resource_import has to be false when working with local files since kognic cannot maintain a reference to your local files and fetch them at a later time.
Create scene from cloud resources
This guide will walk you through the process of uploading a scene where the sources are located on a bucket that you have access to.
Prerequisites
You have successfully followed the Quickstart 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.
To upload scenes using cloud resources you need the following:
- kognic-io >= 2.5.1
- a valid data integration
- a calibration for your scene
- data on your bucket in a file format that kognic supports
Overview
Instead of providing local_file=LocalFile(...) on each resource (image, pointcloud, IMU data) you will instead leave local_file=None and provide external_resource_uri using the native format of your cloud platform i.e. a gs:// or s3:// URL.
Example
The example shows a full 2D+3D scene with IMU data an Ego vehicle poses. It can be reduced to a 2D-only scene by removing the IMU, ego and pointclouds.
Import may be deferred via postpone_external_resource_import creating so called 'Indexed' scenes. ('Indexed' because we only keep an index of what could be in the system and do not fetch the data until the scene is used or manually requested later.)
from kognic.io.client import KognicIOClient
from kognic.io.model.scene import SceneRequest, Frame, ImageResource, SensorResource, Resource, EgoVehiclePose
scene = SceneRequest(
workspace_id="<workspace_id>",
external_id="my_first_scene_from_external_resources",
frames=[
Frame(
frame_id="1",
timestamp_ns=1742225790,
# For 2D-only scenes, omit pointclouds entirely.
pointclouds=[
SensorResource(
external_resource_uri="<uri>",
sensor_name="my_lidar",
local_file=None,
)
],
images=[
ImageResource(
external_resource_uri="<uri>",
sensor_name="my_camera",
start_shutter_timestamp_ns=1742225789,
end_shutter_timestamp_ns=1742225790,
local_file=None,
)
],
# For 2D-only scenes, omit ego_vehicle_pose entirely.
ego_vehicle_pose=EgoVehiclePose(
x=0.0, y=0.0, z=0.0, rotation_x=0.0, rotation_y=0.0, rotation_z=0.0, rotation_w=1.0
)
)
],
calibration_id="<calibration_id>",
# For 2D scenes, omit imudata_resource entirely.
imudata_resource=Resource(
external_resource_uri="<uri>",
local_file=None
),
sensor_specification=None,
should_motion_compensate=False, # Omit for 2D, optionally set for 3D+2D
postpone_external_resource_import=False, # Set true if you want to import at a later point in time
)
client = KognicIOClient()
scene_uuid = client.scene.create_scene(scene).scene_uuid
print("Scene uploaded, got uuid:", scene_uuid)