raillabel.json_format package

Submodules

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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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

Bases: _JSONFormatBase

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

_abc_impl = <_abc._abc_data object>
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).

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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

Bases: _JSONFormatBase

Container of frame information other than annotations.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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

Bases: _JSONFormatBase

Container of annotations of an object in a frame.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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

Bases: _JSONFormatBase

Root RailLabel object.

_abc_impl = <_abc._abc_data 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.

_abc_impl = <_abc._abc_data object>
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

Bases: _JSONFormatBase

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

This specific object contains the intrinsics of a camera sensor.

_abc_impl = <_abc._abc_data object>
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

Bases: _JSONFormatBase

Intrinsic calibration of the stream.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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

Bases: _JSONFormatBase

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

This specific object contains the intrinsics of a radar sensor.

_abc_impl = <_abc._abc_data object>
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

Bases: _JSONFormatBase

Intrinsic calibration of the stream.

_abc_impl = <_abc._abc_data object>
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

Bases: _JSONFormatBase

Syncronization information of a stream in a frame.

_abc_impl = <_abc._abc_data object>
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

Bases: _JSONFormatBase

The sync information.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.

_abc_impl = <_abc._abc_data object>
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.