raillabel.json_format package

Submodules

raillabel.json_format.attributes module

class raillabel.json_format.attributes.JSONAttributes(*, boolean: List[JSONBooleanAttribute] | None = None, num: List[JSONNumAttribute] | None = None, text: List[JSONTextAttribute] | None = None, vec: List[JSONVecAttribute] | None = None)

Bases: _JSONFormatBase

Attributes is the alias of element data that can be nested inside geometric object data.

For example, a certain bounding box can have attributes related to its score, visibility, etc. These values can be nested inside the bounding box as attributes.

boolean: list[JSONBooleanAttribute] | None
model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

num: list[JSONNumAttribute] | None
text: list[JSONTextAttribute] | None
vec: list[JSONVecAttribute] | None

raillabel.json_format.bbox module

class raillabel.json_format.bbox.JSONBbox(*, name: str, val: Tuple[float, float, float, float], coordinate_system: str, uid: UUID | None = None, attributes: JSONAttributes | None = None)

Bases: _JSONFormatBase

A 2D bounding box is defined as a 4-dimensional vector [x, y, w, h].

[x, y] is the center of the bounding box and [w, h] represent the width (horizontal, x-coordinate dimension) and height (vertical, y-coordinate dimension), respectively.

attributes: JSONAttributes | None
coordinate_system: str

Name of the coordinate system in respect of which this object data is expressed.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

This is a string encoding the name of this object data. It is used as index inside the corresponding object data pointers.

uid: UUID | None

This is a string encoding the Universal Unique identifyer of the annotation.

val: tuple[float, float, float, float]

The array of 4 values that define the [x, y, w, h] values of the bbox.

raillabel.json_format.boolean_attribute module

class raillabel.json_format.boolean_attribute.JSONBooleanAttribute(*, name: str, val: bool)

Bases: _JSONFormatBase

A boolean attribute.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

Friendly identifier describing the attribute. Used to track the attribute throughout annotations and frames.

val: bool

The boolean value.

raillabel.json_format.coordinate_system module

class raillabel.json_format.coordinate_system.JSONCoordinateSystem(*, parent: Literal['base', ''], type: Literal['sensor', 'local'], pose_wrt_parent: JSONTransformData | None = None, children: List[str] | None = None)

Bases: _JSONFormatBase

A 3D reference frame.

children: list[str] | None

List of children of this coordinate system.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

parent: Literal['base', '']

This is the string UID of the parent coordinate system this coordinate system is referring to.

pose_wrt_parent: JSONTransformData | None

The transformation with regards to the parent coordinate system.

type: Literal['sensor', 'local']

This is a string that describes the type of the coordinate system, for example, ‘local’, ‘geo’).

raillabel.json_format.cuboid module

class raillabel.json_format.cuboid.JSONCuboid(*, name: str, val: Tuple[float, float, float, float, float, float, float, float, float, float], coordinate_system: str, uid: UUID | None = None, attributes: JSONAttributes | None = None)

Bases: _JSONFormatBase

A cuboid or 3D bounding box.

It is defined by the position of its center, the rotation in 3D, and its dimensions.

attributes: JSONAttributes | None
coordinate_system: str

Name of the coordinate system in respect of which this object data is expressed.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

This is a string encoding the name of this object data. It is used as index inside the corresponding object data pointers.

uid: UUID | None

This is a string encoding the Universal Unique identifyer of the annotation.

val: tuple[float, float, float, float, float, float, float, float, float, float]

List of values encoding the position, rotation and dimensions. It is (x, y, z, qx, qy, qz, qw, sx, sy, sz) where (x, y, z) encodes the position, (qx, qy, qz, qw) encodes the quaternion that encode the rotation, and (sx, sy, sz) are the dimensions of the cuboid in its object coordinate system

raillabel.json_format.element_data_pointer module

class raillabel.json_format.element_data_pointer.JSONElementDataPointer(*, attribute_pointers: Dict[str, Literal['num', 'text', 'boolean', 'vec']], frame_intervals: List[JSONFrameInterval], type: Literal['bbox', 'num', 'poly2d', 'poly3d', 'cuboid', 'vec'])

Bases: _JSONFormatBase

A pointer to element data of elements.

It is indexed by ‘name’, and containing information about the element data type, for example, bounding box, cuboid, and the frame intervals in which this element_data exists within an element. That means, these pointers can be used to explore element data dynamic information within the JSON content.

attribute_pointers: dict[str, Literal['num', 'text', 'boolean', 'vec']]

This is a JSON object which contains pointers to the attributes of the element data pointed by this pointer. The attributes pointer keys shall be the ‘name’ of the attribute of the element data this pointer points to.

frame_intervals: list[JSONFrameInterval]

List of frame intervals of the element data pointed by this pointer.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

type: Literal['bbox', 'num', 'poly2d', 'poly3d', 'cuboid', 'vec']

Type of the element data pointed by this pointer.

raillabel.json_format.frame module

class raillabel.json_format.frame.JSONFrame

Bases: _JSONFormatBase

A frame is a container of dynamic, timewise, information.

frame_properties: JSONFrameProperties | None

Container of frame information other than annotations.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

objects: dict[UUID, JSONObjectData] | None

This is a JSON object that contains dynamic information on RailLabel objects. Object keys are strings containing 32 bytes UUIDs. Object values contain an ‘object_data’ JSON object.

class raillabel.json_format.frame.JSONFrameData(*, num: List[JSONNum] | None = None)

Bases: _JSONFormatBase

Additional data to describe attributes of the frame (like GPS position).

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

num: list[JSONNum] | None

List of ‘num’ that describe this frame.

class raillabel.json_format.frame.JSONFrameProperties

Bases: _JSONFormatBase

Container of frame information other than annotations.

frame_data: JSONFrameData | None

Additional data to describe attributes of the frame (like GPS position).

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

streams: dict[str, JSONStreamSync] | None

Stream timestamps for synchronization.

timestamp: Decimal | str | None

The timestamp indicates a time instant as a UTC string or numerical value to describe this frame.

raillabel.json_format.frame_interval module

class raillabel.json_format.frame_interval.JSONFrameInterval(*, frame_start: int, frame_end: int)

Bases: _JSONFormatBase

A frame interval defines a starting and ending frame number as a closed interval.

That means the interval includes the limit frame numbers.

frame_end: int

Ending frame number of the interval.

frame_start: int

Initial frame number of the interval.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

raillabel.json_format.metadata module

class raillabel.json_format.metadata.JSONMetadata(*, schema_version: Literal['1.0.0'], name: str | None = None, subschema_version: str | None = None, exporter_version: str | None = None, file_version: str | None = None, tagged_file: str | None = None, annotator: str | None = None, comment: str | None = None, **extra_data: Any)

Bases: BaseModel

Metadata about the annotation file itself.

annotator: str | None

The person or organization responsible for annotating the file.

comment: str | None

Additional information or description about the annotation content.

exporter_version: str | None

Version identifyer of the exporter software.

file_version: str | None

Version number of the OpenLABEL annotation content.

model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str | None

Name of the OpenLABEL annotation content.

schema_version: Literal['1.0.0']

Version number of the OpenLABEL schema this annotation file follows.

subschema_version: str | None

Version number of the RailLabel subschema this annotation file follows.

tagged_file: str | None

File name or URI of the data file being tagged.

raillabel.json_format.num module

class raillabel.json_format.num.JSONNum(*, name: str, val: float, coordinate_system: str | None = None, uid: UUID | None = None)

Bases: _JSONFormatBase

A number.

coordinate_system: str | None

Name of the coordinate system in respect of which this object data is expressed.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

This is a string encoding the name of this object data. It is used as index inside the corresponding object data pointers.

uid: UUID | None

This is a string encoding the Universal Unique identifyer of the annotation.

val: float

The numerical value of the number.

raillabel.json_format.num_attribute module

class raillabel.json_format.num_attribute.JSONNumAttribute(*, name: str, val: float)

Bases: _JSONFormatBase

A number attribute.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

Friendly identifier describing the attribute. Used to track the attribute throughout annotations and frames.

val: float

The number value.

raillabel.json_format.object module

class raillabel.json_format.object.JSONObject(*, name: str, type: str, frame_intervals: List[JSONFrameInterval] | None = None, object_data_pointers: Dict[str, JSONElementDataPointer] | None = None)

Bases: _JSONFormatBase

An object is the main type of annotation element.

Object is designed to represent spatiotemporal entities, such as physical objects in the real world. Objects shall have a name and type. Objects may have static and dynamic data. Objects are the only type of elements that may have geometric data, such as bounding boxes, cuboids, polylines, images, etc.

frame_intervals: list[JSONFrameInterval] | None

The array of frame intervals where this object exists or is defined.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

Name of the object. It is a friendly name and not used for indexing.

object_data_pointers: dict[str, JSONElementDataPointer] | None
type: str

The type of an object defines the class the object corresponds to.

raillabel.json_format.object_data module

class raillabel.json_format.object_data.JSONAnnotations(*, bbox: List[JSONBbox] | None = None, cuboid: List[JSONCuboid] | None = None, poly2d: List[JSONPoly2d] | None = None, poly3d: List[JSONPoly3d] | None = None, vec: List[JSONVec] | None = None)

Bases: _JSONFormatBase

Container of the annotations by type.

bbox: list[JSONBbox] | None
cuboid: list[JSONCuboid] | None
model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

poly2d: list[JSONPoly2d] | None
poly3d: list[JSONPoly3d] | None
vec: list[JSONVec] | None
class raillabel.json_format.object_data.JSONObjectData

Bases: _JSONFormatBase

Container of annotations of an object in a frame.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

object_data: JSONAnnotations

raillabel.json_format.poly2d module

class raillabel.json_format.poly2d.JSONPoly2d(*, name: str, val: List[float | str], closed: bool, mode: Literal['MODE_POLY2D_ABSOLUTE'], coordinate_system: str, uid: UUID | None = None, attributes: JSONAttributes | None = None)

Bases: _JSONFormatBase

A 2D polyline defined as a sequence of 2D points.

attributes: JSONAttributes | None
closed: bool

A boolean that defines whether the polyline is closed or not. In case it is closed, it is assumed that the last point of the sequence is connected with the first one.

coordinate_system: str

Name of the coordinate system in respect of which this object data is expressed.

mode: Literal['MODE_POLY2D_ABSOLUTE']

Mode of the polyline describes how the points should be arranged in the images. MODE_POLY2D_ABSOLUTE means that any point defined by an x-value followed by a y-value is the absolute position.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

This is a string encoding the name of this object data. It is used as index inside the corresponding object data pointers.

uid: UUID | None

This is a string encoding the Universal Unique identifyer of the annotation.

val: list[float | str]

List of numerical values of the polyline, according to its mode.

raillabel.json_format.poly3d module

class raillabel.json_format.poly3d.JSONPoly3d(*, name: str, val: List[float], closed: bool, coordinate_system: str, uid: UUID | None = None, attributes: JSONAttributes | None = None)

Bases: _JSONFormatBase

A 3D polyline defined as a sequence of 3D points.

attributes: JSONAttributes | None
closed: bool

A boolean that defines whether the polyline is closed or not. In case it is closed, it is assumed that the last point of the sequence is connected with the first one.

coordinate_system: str

Name of the coordinate system in respect of which this object data is expressed.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

This is a string encoding the name of this object data. It is used as index inside the corresponding object data pointers.

uid: UUID | None

This is a string encoding the Universal Unique identifyer of the annotation.

val: list[float]

List of numerical values of the polyline, according to its mode.

raillabel.json_format.scene module

class raillabel.json_format.scene.JSONScene

Bases: _JSONFormatBase

Root RailLabel object.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

openlabel: JSONSceneContent
class raillabel.json_format.scene.JSONSceneContent(*, metadata: JSONMetadata, coordinate_systems: Dict[str, JSONCoordinateSystem] | None = None, streams: Dict[str, JSONStreamCamera | JSONStreamOther | JSONStreamRadar] | None = None, objects: Dict[UUID, JSONObject] | None = None, frames: Dict[int, JSONFrame] | None = None, frame_intervals: List[JSONFrameInterval] | None = None)

Bases: _JSONFormatBase

Container of all scene content.

coordinate_systems: dict[str, JSONCoordinateSystem] | None
frame_intervals: list[JSONFrameInterval] | None
frames: dict[int, JSONFrame] | None
metadata: JSONMetadata
model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

objects: dict[UUID, JSONObject] | None
streams: dict[str, JSONStreamCamera | JSONStreamOther | JSONStreamRadar] | None

raillabel.json_format.stream_camera module

class raillabel.json_format.stream_camera.JSONIntrinsicsPinhole(*, camera_matrix: Tuple[float, float, float, float, float, float, float, float, float, float, float, float], distortion_coeffs: Tuple[float, float, float, float, float], height_px: int, width_px: int)

Bases: _JSONFormatBase

JSON object defining an instance of the intrinsic parameters of a pinhole camera.

camera_matrix: tuple[float, float, float, float, float, float, float, float, float, float, float, float]

This is a 3x4 camera matrix which projects 3D homogeneous points (4x1) from a camera coordinate system into the image plane (3x1). This is the usual K matrix for camera projection as in OpenCV. It is extended from 3x3 to 3x4 to enable its direct utilisation to project 4x1 homogeneous 3D points. The matrix is defined to follow the camera model: x-to-right, y-down, z-forward. The following equation applies: x_img = camera_matrix * X_ccs.

distortion_coeffs: tuple[float, float, float, float, float]

This is the array 1x5 radial and tangential distortion coefficients.

height_px: int

Height of the camera output in pixel.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

width_px: int

Width of the camera output in pixel.

class raillabel.json_format.stream_camera.JSONStreamCamera

Bases: _JSONFormatBase

A stream describes the source of a data sequence, usually a sensor.

This specific object contains the intrinsics of a camera sensor.

description: str | None

Description of the stream.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

stream_properties: JSONStreamCameraProperties

Intrinsic calibration of the stream.

type: Literal['camera']

A string encoding the type of the stream.

uri: str | None

A string encoding the subdirectory containing the sensor files.

class raillabel.json_format.stream_camera.JSONStreamCameraProperties

Bases: _JSONFormatBase

Intrinsic calibration of the stream.

intrinsics_pinhole: JSONIntrinsicsPinhole
model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

raillabel.json_format.stream_other module

class raillabel.json_format.stream_other.JSONStreamOther(*, type: Literal['lidar', 'gps_imu', 'other'], uri: str | None = None, description: str | None = None)

Bases: _JSONFormatBase

A stream describes the source of a data sequence, usually a sensor.

This specific object describes a sensor without intrinsic calibration.

description: str | None

Description of the stream.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

type: Literal['lidar', 'gps_imu', 'other']

A string encoding the type of the stream.

uri: str | None

A string encoding the subdirectory containing the sensor files.

raillabel.json_format.stream_radar module

class raillabel.json_format.stream_radar.JSONIntrinsicsRadar(*, resolution_px_per_m: float, height_px: int, width_px: int)

Bases: _JSONFormatBase

JSON object defining an instance of the intrinsic parameters of a radar.

height_px: int

Height of the radar output in pixel.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

resolution_px_per_m: float

Number correlating pixel in the output image to a position relative to the sensor in meters.

width_px: int

Width of the radar output in pixel.

class raillabel.json_format.stream_radar.JSONStreamRadar

Bases: _JSONFormatBase

A stream describes the source of a data sequence, usually a sensor.

This specific object contains the intrinsics of a radar sensor.

description: str | None

Description of the stream.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

stream_properties: JSONStreamRadarProperties

Intrinsic calibration of the stream.

type: Literal['radar']

A string encoding the type of the stream.

uri: str | None

A string encoding the subdirectory containing the sensor files.

class raillabel.json_format.stream_radar.JSONStreamRadarProperties

Bases: _JSONFormatBase

Intrinsic calibration of the stream.

intrinsics_radar: JSONIntrinsicsRadar
model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

raillabel.json_format.stream_sync module

class raillabel.json_format.stream_sync.JSONStreamSync

Bases: _JSONFormatBase

Syncronization information of a stream in a frame.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

stream_properties: JSONStreamSyncProperties
uri: str | None
class raillabel.json_format.stream_sync.JSONStreamSyncProperties

Bases: _JSONFormatBase

The sync information.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

sync: JSONStreamSyncTimestamp
class raillabel.json_format.stream_sync.JSONStreamSyncTimestamp(*, timestamp: Decimal | str)

Bases: _JSONFormatBase

The timestamp of a stream sync.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

timestamp: Decimal | str

raillabel.json_format.text_attribute module

class raillabel.json_format.text_attribute.JSONTextAttribute(*, name: str, val: str)

Bases: _JSONFormatBase

A text attribute.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

Friendly identifier describing the attribute. Used to track the attribute throughout annotations and frames.

val: str

The text value.

raillabel.json_format.transform_data module

class raillabel.json_format.transform_data.JSONTransformData(*, translation: Tuple[float, float, float], quaternion: Tuple[float, float, float, float])

Bases: _JSONFormatBase

The translation and rotation of one coordinate system to another.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

quaternion: tuple[float, float, float, float]

List of 3 values encoding the translation vector (x, y, z)

translation: tuple[float, float, float]

List of 4 values encoding a quaternion (x, y, z, w).

raillabel.json_format.vec module

class raillabel.json_format.vec.JSONVec(*, name: str, val: List[float], coordinate_system: str, uid: UUID | None = None, type: Literal['values', 'range'] | None = None, attributes: JSONAttributes | None = None)

Bases: _JSONFormatBase

A vector (list) of numbers.

attributes: JSONAttributes | None
coordinate_system: str

Name of the coordinate system in respect of which this object data is expressed.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

This is a string encoding the name of this object data. It is used as index inside the corresponding object data pointers.

type: Literal['values', 'range'] | None

This attribute specifies whether the vector shall be considered as a descriptor of individual values or as a definition of a range.

uid: UUID | None

This is a string encoding the Universal Unique identifyer of the annotation.

val: list[float]

The numerical values of the vector (list) of numbers.

raillabel.json_format.vec_attribute module

class raillabel.json_format.vec_attribute.JSONVecAttribute(*, name: str, val: List[float | str])

Bases: _JSONFormatBase

A vec attribute.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

Friendly identifier describing the attribute. Used to track the attribute throughout annotations and frames.

val: list[float | str]

The value vector of the attribute.

Module contents

Package for classes representing the direct RailLabel JSON objects.

class raillabel.json_format.JSONAnnotations(*, bbox: List[JSONBbox] | None = None, cuboid: List[JSONCuboid] | None = None, poly2d: List[JSONPoly2d] | None = None, poly3d: List[JSONPoly3d] | None = None, vec: List[JSONVec] | None = None)

Bases: _JSONFormatBase

Container of the annotations by type.

bbox: list[JSONBbox] | None
cuboid: list[JSONCuboid] | None
model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

poly2d: list[JSONPoly2d] | None
poly3d: list[JSONPoly3d] | None
vec: list[JSONVec] | None
class raillabel.json_format.JSONAttributes(*, boolean: List[JSONBooleanAttribute] | None = None, num: List[JSONNumAttribute] | None = None, text: List[JSONTextAttribute] | None = None, vec: List[JSONVecAttribute] | None = None)

Bases: _JSONFormatBase

Attributes is the alias of element data that can be nested inside geometric object data.

For example, a certain bounding box can have attributes related to its score, visibility, etc. These values can be nested inside the bounding box as attributes.

boolean: list[JSONBooleanAttribute] | None
model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

num: list[JSONNumAttribute] | None
text: list[JSONTextAttribute] | None
vec: list[JSONVecAttribute] | None
class raillabel.json_format.JSONBbox(*, name: str, val: Tuple[float, float, float, float], coordinate_system: str, uid: UUID | None = None, attributes: JSONAttributes | None = None)

Bases: _JSONFormatBase

A 2D bounding box is defined as a 4-dimensional vector [x, y, w, h].

[x, y] is the center of the bounding box and [w, h] represent the width (horizontal, x-coordinate dimension) and height (vertical, y-coordinate dimension), respectively.

attributes: JSONAttributes | None
coordinate_system: str

Name of the coordinate system in respect of which this object data is expressed.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

This is a string encoding the name of this object data. It is used as index inside the corresponding object data pointers.

uid: UUID | None

This is a string encoding the Universal Unique identifyer of the annotation.

val: tuple[float, float, float, float]

The array of 4 values that define the [x, y, w, h] values of the bbox.

class raillabel.json_format.JSONBooleanAttribute(*, name: str, val: bool)

Bases: _JSONFormatBase

A boolean attribute.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

Friendly identifier describing the attribute. Used to track the attribute throughout annotations and frames.

val: bool

The boolean value.

class raillabel.json_format.JSONCoordinateSystem(*, parent: Literal['base', ''], type: Literal['sensor', 'local'], pose_wrt_parent: JSONTransformData | None = None, children: List[str] | None = None)

Bases: _JSONFormatBase

A 3D reference frame.

children: list[str] | None

List of children of this coordinate system.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

parent: Literal['base', '']

This is the string UID of the parent coordinate system this coordinate system is referring to.

pose_wrt_parent: JSONTransformData | None

The transformation with regards to the parent coordinate system.

type: Literal['sensor', 'local']

This is a string that describes the type of the coordinate system, for example, ‘local’, ‘geo’).

class raillabel.json_format.JSONCuboid(*, name: str, val: Tuple[float, float, float, float, float, float, float, float, float, float], coordinate_system: str, uid: UUID | None = None, attributes: JSONAttributes | None = None)

Bases: _JSONFormatBase

A cuboid or 3D bounding box.

It is defined by the position of its center, the rotation in 3D, and its dimensions.

attributes: JSONAttributes | None
coordinate_system: str

Name of the coordinate system in respect of which this object data is expressed.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

This is a string encoding the name of this object data. It is used as index inside the corresponding object data pointers.

uid: UUID | None

This is a string encoding the Universal Unique identifyer of the annotation.

val: tuple[float, float, float, float, float, float, float, float, float, float]

List of values encoding the position, rotation and dimensions. It is (x, y, z, qx, qy, qz, qw, sx, sy, sz) where (x, y, z) encodes the position, (qx, qy, qz, qw) encodes the quaternion that encode the rotation, and (sx, sy, sz) are the dimensions of the cuboid in its object coordinate system

class raillabel.json_format.JSONElementDataPointer(*, attribute_pointers: Dict[str, Literal['num', 'text', 'boolean', 'vec']], frame_intervals: List[JSONFrameInterval], type: Literal['bbox', 'num', 'poly2d', 'poly3d', 'cuboid', 'vec'])

Bases: _JSONFormatBase

A pointer to element data of elements.

It is indexed by ‘name’, and containing information about the element data type, for example, bounding box, cuboid, and the frame intervals in which this element_data exists within an element. That means, these pointers can be used to explore element data dynamic information within the JSON content.

attribute_pointers: dict[str, Literal['num', 'text', 'boolean', 'vec']]

This is a JSON object which contains pointers to the attributes of the element data pointed by this pointer. The attributes pointer keys shall be the ‘name’ of the attribute of the element data this pointer points to.

frame_intervals: list[JSONFrameInterval]

List of frame intervals of the element data pointed by this pointer.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

type: Literal['bbox', 'num', 'poly2d', 'poly3d', 'cuboid', 'vec']

Type of the element data pointed by this pointer.

class raillabel.json_format.JSONFrame(*, frame_properties: JSONFrameProperties | None = None, objects: Dict[UUID, JSONObjectData] | None = None)

Bases: _JSONFormatBase

A frame is a container of dynamic, timewise, information.

frame_properties: JSONFrameProperties | None

Container of frame information other than annotations.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

objects: dict[UUID, JSONObjectData] | None

This is a JSON object that contains dynamic information on RailLabel objects. Object keys are strings containing 32 bytes UUIDs. Object values contain an ‘object_data’ JSON object.

class raillabel.json_format.JSONFrameData(*, num: List[JSONNum] | None = None)

Bases: _JSONFormatBase

Additional data to describe attributes of the frame (like GPS position).

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

num: list[JSONNum] | None

List of ‘num’ that describe this frame.

class raillabel.json_format.JSONFrameInterval(*, frame_start: int, frame_end: int)

Bases: _JSONFormatBase

A frame interval defines a starting and ending frame number as a closed interval.

That means the interval includes the limit frame numbers.

frame_end: int

Ending frame number of the interval.

frame_start: int

Initial frame number of the interval.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class raillabel.json_format.JSONFrameProperties(*, timestamp: Decimal | str | None = None, streams: Dict[str, JSONStreamSync] | None = None, frame_data: JSONFrameData | None = None)

Bases: _JSONFormatBase

Container of frame information other than annotations.

frame_data: JSONFrameData | None

Additional data to describe attributes of the frame (like GPS position).

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

streams: dict[str, JSONStreamSync] | None

Stream timestamps for synchronization.

timestamp: Decimal | str | None

The timestamp indicates a time instant as a UTC string or numerical value to describe this frame.

class raillabel.json_format.JSONIntrinsicsPinhole(*, camera_matrix: Tuple[float, float, float, float, float, float, float, float, float, float, float, float], distortion_coeffs: Tuple[float, float, float, float, float], height_px: int, width_px: int)

Bases: _JSONFormatBase

JSON object defining an instance of the intrinsic parameters of a pinhole camera.

camera_matrix: tuple[float, float, float, float, float, float, float, float, float, float, float, float]

This is a 3x4 camera matrix which projects 3D homogeneous points (4x1) from a camera coordinate system into the image plane (3x1). This is the usual K matrix for camera projection as in OpenCV. It is extended from 3x3 to 3x4 to enable its direct utilisation to project 4x1 homogeneous 3D points. The matrix is defined to follow the camera model: x-to-right, y-down, z-forward. The following equation applies: x_img = camera_matrix * X_ccs.

distortion_coeffs: tuple[float, float, float, float, float]

This is the array 1x5 radial and tangential distortion coefficients.

height_px: int

Height of the camera output in pixel.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

width_px: int

Width of the camera output in pixel.

class raillabel.json_format.JSONIntrinsicsRadar(*, resolution_px_per_m: float, height_px: int, width_px: int)

Bases: _JSONFormatBase

JSON object defining an instance of the intrinsic parameters of a radar.

height_px: int

Height of the radar output in pixel.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

resolution_px_per_m: float

Number correlating pixel in the output image to a position relative to the sensor in meters.

width_px: int

Width of the radar output in pixel.

class raillabel.json_format.JSONMetadata(*, schema_version: Literal['1.0.0'], name: str | None = None, subschema_version: str | None = None, exporter_version: str | None = None, file_version: str | None = None, tagged_file: str | None = None, annotator: str | None = None, comment: str | None = None, **extra_data: Any)

Bases: BaseModel

Metadata about the annotation file itself.

annotator: str | None

The person or organization responsible for annotating the file.

comment: str | None

Additional information or description about the annotation content.

exporter_version: str | None

Version identifyer of the exporter software.

file_version: str | None

Version number of the OpenLABEL annotation content.

model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str | None

Name of the OpenLABEL annotation content.

schema_version: Literal['1.0.0']

Version number of the OpenLABEL schema this annotation file follows.

subschema_version: str | None

Version number of the RailLabel subschema this annotation file follows.

tagged_file: str | None

File name or URI of the data file being tagged.

class raillabel.json_format.JSONNum(*, name: str, val: float, coordinate_system: str | None = None, uid: UUID | None = None)

Bases: _JSONFormatBase

A number.

coordinate_system: str | None

Name of the coordinate system in respect of which this object data is expressed.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

This is a string encoding the name of this object data. It is used as index inside the corresponding object data pointers.

uid: UUID | None

This is a string encoding the Universal Unique identifyer of the annotation.

val: float

The numerical value of the number.

class raillabel.json_format.JSONNumAttribute(*, name: str, val: float)

Bases: _JSONFormatBase

A number attribute.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

Friendly identifier describing the attribute. Used to track the attribute throughout annotations and frames.

val: float

The number value.

class raillabel.json_format.JSONObject(*, name: str, type: str, frame_intervals: List[JSONFrameInterval] | None = None, object_data_pointers: Dict[str, JSONElementDataPointer] | None = None)

Bases: _JSONFormatBase

An object is the main type of annotation element.

Object is designed to represent spatiotemporal entities, such as physical objects in the real world. Objects shall have a name and type. Objects may have static and dynamic data. Objects are the only type of elements that may have geometric data, such as bounding boxes, cuboids, polylines, images, etc.

frame_intervals: list[JSONFrameInterval] | None

The array of frame intervals where this object exists or is defined.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

Name of the object. It is a friendly name and not used for indexing.

object_data_pointers: dict[str, JSONElementDataPointer] | None
type: str

The type of an object defines the class the object corresponds to.

class raillabel.json_format.JSONObjectData(*, object_data: JSONAnnotations)

Bases: _JSONFormatBase

Container of annotations of an object in a frame.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

object_data: JSONAnnotations
class raillabel.json_format.JSONPoly2d(*, name: str, val: List[float | str], closed: bool, mode: Literal['MODE_POLY2D_ABSOLUTE'], coordinate_system: str, uid: UUID | None = None, attributes: JSONAttributes | None = None)

Bases: _JSONFormatBase

A 2D polyline defined as a sequence of 2D points.

attributes: JSONAttributes | None
closed: bool

A boolean that defines whether the polyline is closed or not. In case it is closed, it is assumed that the last point of the sequence is connected with the first one.

coordinate_system: str

Name of the coordinate system in respect of which this object data is expressed.

mode: Literal['MODE_POLY2D_ABSOLUTE']

Mode of the polyline describes how the points should be arranged in the images. MODE_POLY2D_ABSOLUTE means that any point defined by an x-value followed by a y-value is the absolute position.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

This is a string encoding the name of this object data. It is used as index inside the corresponding object data pointers.

uid: UUID | None

This is a string encoding the Universal Unique identifyer of the annotation.

val: list[float | str]

List of numerical values of the polyline, according to its mode.

class raillabel.json_format.JSONPoly3d(*, name: str, val: List[float], closed: bool, coordinate_system: str, uid: UUID | None = None, attributes: JSONAttributes | None = None)

Bases: _JSONFormatBase

A 3D polyline defined as a sequence of 3D points.

attributes: JSONAttributes | None
closed: bool

A boolean that defines whether the polyline is closed or not. In case it is closed, it is assumed that the last point of the sequence is connected with the first one.

coordinate_system: str

Name of the coordinate system in respect of which this object data is expressed.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

This is a string encoding the name of this object data. It is used as index inside the corresponding object data pointers.

uid: UUID | None

This is a string encoding the Universal Unique identifyer of the annotation.

val: list[float]

List of numerical values of the polyline, according to its mode.

class raillabel.json_format.JSONScene(*, openlabel: JSONSceneContent)

Bases: _JSONFormatBase

Root RailLabel object.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

openlabel: JSONSceneContent
class raillabel.json_format.JSONSceneContent(*, metadata: JSONMetadata, coordinate_systems: Dict[str, JSONCoordinateSystem] | None = None, streams: Dict[str, JSONStreamCamera | JSONStreamOther | JSONStreamRadar] | None = None, objects: Dict[UUID, JSONObject] | None = None, frames: Dict[int, JSONFrame] | None = None, frame_intervals: List[JSONFrameInterval] | None = None)

Bases: _JSONFormatBase

Container of all scene content.

coordinate_systems: dict[str, JSONCoordinateSystem] | None
frame_intervals: list[JSONFrameInterval] | None
frames: dict[int, JSONFrame] | None
metadata: JSONMetadata
model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

objects: dict[UUID, JSONObject] | None
streams: dict[str, JSONStreamCamera | JSONStreamOther | JSONStreamRadar] | None
class raillabel.json_format.JSONStreamCamera(*, type: Literal['camera'], stream_properties: JSONStreamCameraProperties, uri: str | None = None, description: str | None = None)

Bases: _JSONFormatBase

A stream describes the source of a data sequence, usually a sensor.

This specific object contains the intrinsics of a camera sensor.

description: str | None

Description of the stream.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

stream_properties: JSONStreamCameraProperties

Intrinsic calibration of the stream.

type: Literal['camera']

A string encoding the type of the stream.

uri: str | None

A string encoding the subdirectory containing the sensor files.

class raillabel.json_format.JSONStreamCameraProperties(*, intrinsics_pinhole: JSONIntrinsicsPinhole)

Bases: _JSONFormatBase

Intrinsic calibration of the stream.

intrinsics_pinhole: JSONIntrinsicsPinhole
model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class raillabel.json_format.JSONStreamOther(*, type: Literal['lidar', 'gps_imu', 'other'], uri: str | None = None, description: str | None = None)

Bases: _JSONFormatBase

A stream describes the source of a data sequence, usually a sensor.

This specific object describes a sensor without intrinsic calibration.

description: str | None

Description of the stream.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

type: Literal['lidar', 'gps_imu', 'other']

A string encoding the type of the stream.

uri: str | None

A string encoding the subdirectory containing the sensor files.

class raillabel.json_format.JSONStreamRadar(*, type: Literal['radar'], stream_properties: JSONStreamRadarProperties, uri: str | None = None, description: str | None = None)

Bases: _JSONFormatBase

A stream describes the source of a data sequence, usually a sensor.

This specific object contains the intrinsics of a radar sensor.

description: str | None

Description of the stream.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

stream_properties: JSONStreamRadarProperties

Intrinsic calibration of the stream.

type: Literal['radar']

A string encoding the type of the stream.

uri: str | None

A string encoding the subdirectory containing the sensor files.

class raillabel.json_format.JSONStreamRadarProperties(*, intrinsics_radar: JSONIntrinsicsRadar)

Bases: _JSONFormatBase

Intrinsic calibration of the stream.

intrinsics_radar: JSONIntrinsicsRadar
model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class raillabel.json_format.JSONStreamSync(*, stream_properties: JSONStreamSyncProperties, uri: str | None = None)

Bases: _JSONFormatBase

Syncronization information of a stream in a frame.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

stream_properties: JSONStreamSyncProperties
uri: str | None
class raillabel.json_format.JSONStreamSyncProperties(*, sync: JSONStreamSyncTimestamp)

Bases: _JSONFormatBase

The sync information.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

sync: JSONStreamSyncTimestamp
class raillabel.json_format.JSONStreamSyncTimestamp(*, timestamp: Decimal | str)

Bases: _JSONFormatBase

The timestamp of a stream sync.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

timestamp: Decimal | str
class raillabel.json_format.JSONTextAttribute(*, name: str, val: str)

Bases: _JSONFormatBase

A text attribute.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

Friendly identifier describing the attribute. Used to track the attribute throughout annotations and frames.

val: str

The text value.

class raillabel.json_format.JSONTransformData(*, translation: Tuple[float, float, float], quaternion: Tuple[float, float, float, float])

Bases: _JSONFormatBase

The translation and rotation of one coordinate system to another.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

quaternion: tuple[float, float, float, float]

List of 3 values encoding the translation vector (x, y, z)

translation: tuple[float, float, float]

List of 4 values encoding a quaternion (x, y, z, w).

class raillabel.json_format.JSONVec(*, name: str, val: List[float], coordinate_system: str, uid: UUID | None = None, type: Literal['values', 'range'] | None = None, attributes: JSONAttributes | None = None)

Bases: _JSONFormatBase

A vector (list) of numbers.

attributes: JSONAttributes | None
coordinate_system: str

Name of the coordinate system in respect of which this object data is expressed.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

This is a string encoding the name of this object data. It is used as index inside the corresponding object data pointers.

type: Literal['values', 'range'] | None

This attribute specifies whether the vector shall be considered as a descriptor of individual values or as a definition of a range.

uid: UUID | None

This is a string encoding the Universal Unique identifyer of the annotation.

val: list[float]

The numerical values of the vector (list) of numbers.

class raillabel.json_format.JSONVecAttribute(*, name: str, val: List[float | str])

Bases: _JSONFormatBase

A vec attribute.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

Friendly identifier describing the attribute. Used to track the attribute throughout annotations and frames.

val: list[float | str]

The value vector of the attribute.