raillabel.format.scene module

class raillabel.format.scene.Scene(metadata: ~raillabel.format.metadata.Metadata, sensors: dict[str, ~raillabel.format.camera.Camera | ~raillabel.format.lidar.Lidar | ~raillabel.format.radar.Radar | ~raillabel.format.gps_imu.GpsImu | ~raillabel.format.other_sensor.OtherSensor] = <factory>, objects: dict[~uuid.UUID, ~raillabel.format.object.Object] = <factory>, frames: dict[int, ~raillabel.format.frame.Frame] = <factory>)

Bases: object

The root RailLabel class, which contains all data.

Examples: You can load scenes like this:

import raillabel
scene = raillabel.load("path/to/scene.json")

The scenes then contain all of the data. This is how you can iterate over the annotations:

for frame in scene.frames.values():
    for annotation in frame.annotations.values():
        pass  # do something with the annotation here
filter(filters: list[_FilterAbc]) Scene

Return a scene with annotations, sensors, objects and frames excluded.

Example:

from raillabel.filter import (
    IncludeObjectTypeFilter,
    ExcludeAnnotationTypeFilter,
    StartTimeFilter, ExcludeFrameIdFilter,
    IncludeAttributesFilter
)

scene_with_only_trains = scene.filter([IncludeObjectTypeFilter(["rail_vehicle"])])

scene_without_bboxs = scene.filter([ExcludeAnnotationTypeFilter(["bbox"])])

cut_scene_with_only_red_trains = scene.filter([
    StartTimeFilter("1587349200.004200000"),
    ExcludeFrameIdFilter([2, 4]),
    IncludeObjectTypeFilter(["rail_vehicle"]),
    IncludeAttributesFilter({"color": "red"}),
])
frames: dict[int, Frame]

A container of dynamic, timewise, information. Keys are the frame integer number.

classmethod from_json(json: JSONScene) Scene

Construct a scene from a json object.

metadata: Metadata

Container of information about the annotation file itself.

objects: dict[UUID, Object]

Unique objects (like a specific person) in this scene. Keys are object uuids

sensors: dict[str, Camera | Lidar | Radar | GpsImu | OtherSensor]

The sensors used in this scene. Keys are sensor names.

to_json() JSONScene

Export this scene into the RailLabel JSON format.

raillabel.format.scene._annotation_passes_all_filters(annotation_id: UUID, annotation: Bbox | Cuboid | Poly2d | Poly3d | Seg3d, annotation_filters: list[_AnnotationLevelFilter], scene: Scene) bool
raillabel.format.scene._coordinate_systems_to_json(sensors: dict[str, Camera | Lidar | Radar | GpsImu | OtherSensor]) dict[str, JSONCoordinateSystem]
raillabel.format.scene._filter_annotations(frame: Frame, annotation_filters: list[_AnnotationLevelFilter], scene: Scene) dict[UUID, Bbox | Cuboid | Poly2d | Poly3d | Seg3d]
raillabel.format.scene._filter_frames(scene: Scene, frame_filters: list[_FrameLevelFilter], annotation_filters: list[_AnnotationLevelFilter]) dict[int, Frame]
raillabel.format.scene._frame_passes_all_filters(frame_id: int, frame: Frame, frame_filters: list[_FrameLevelFilter]) bool
raillabel.format.scene._frames_from_json(json_frames: dict[int, JSONFrame] | None) dict[int, Frame]
raillabel.format.scene._get_used_objects(scene: Scene, filtered_scene: Scene) dict[UUID, Object]
raillabel.format.scene._get_used_sensors(scene: Scene, filtered_scene: Scene) dict[str, Camera | Lidar | Radar | GpsImu | OtherSensor]
raillabel.format.scene._objects_from_json(json_objects: dict[UUID, JSONObject] | None) dict[UUID, Object]
raillabel.format.scene._remove_unused_sensor_references(filtered_scene: Scene) Scene
raillabel.format.scene._sensors_from_json(json_streams: dict[str, JSONStreamCamera | JSONStreamOther | JSONStreamRadar] | None, json_coordinate_systems: dict[str, JSONCoordinateSystem] | None) dict[str, Camera | Lidar | Radar | GpsImu | OtherSensor]
raillabel.format.scene._separate_filters(all_filters: list[_FilterAbc]) tuple[list[_FrameLevelFilter], list[_AnnotationLevelFilter]]