Skip to content

viewer

ViewerBuilder

ViewerBuilder()

Builder for creating a RerunViewer instance.

Examples:

>>> from t4_devkit.viewer import ViewerBuilder
>>> viewer = (
        ViewerBuilder()
        .with_spatial3d()
        .with_spatial2d(cameras=["CAM_FRONT", "CAM_BACK"])
        .with_labels(label2id={"car": 1, "pedestrian": 2})
        .with_streetmap(latlon=[48.8566, 2.3522])
        .build(app_id="my_viewer")
    )

PointCloudColorMode

Bases: str, Enum

Color mode of point cloud.

RerunViewer

RerunViewer(
    app_id: str,
    config: ViewerConfig = ViewerConfig(),
    save_dir: str | None = None,
)

A viewer class that renders some components powered by rerun.

Construct a new object.

Parameters:

  • app_id

    (str) –

    Application ID.

  • config

    (ViewerConfig, default: ViewerConfig() ) –

    Configuration of the viewer.

  • save_dir

    (str | None, default: None ) –

    Directory path to save the recording. Viewer will be spawned if it is None, otherwise not.

Examples:

>>> from t4_devkit.viewer import ViewerBuilder
>>> viewer = (
        ViewerBuilder()
        .with_spatial3d()
        .with_spatial2d(cameras=["CAM_FRONT", "CAM_BACK"])
        .with_labels(label2id={"car": 1, "pedestrian": 2})
        .with_streetmap(latlon=[48.8566, 2.3522])
        .build(app_id="my_viewer")
    )

render_box3ds

render_box3ds(
    seconds: float, boxes: Sequence[Box3D]
) -> None
render_box3ds(
    seconds: float,
    frame_id: str,
    centers: Sequence[Vector3Like],
    rotations: Sequence[RotationLike],
    sizes: Sequence[Vector3Like],
    class_ids: Sequence[int],
    velocities: Sequence[Vector3Like] | None = None,
    uuids: Sequence[str] | None = None,
    futures: Sequence[Future] | None = None,
) -> None
render_box3ds(*args, **kwargs) -> None

Render 3D boxes.

render_box2ds

render_box2ds(
    seconds: float, boxes: Sequence[Box2D]
) -> None
render_box2ds(
    seconds: float,
    camera: str,
    rois: Sequence[RoiLike],
    class_ids: Sequence[int],
    uuids: Sequence[str] | None = None,
) -> None
render_box2ds(*args, **kwargs) -> None

Render 2D boxes.

render_segmentation2d

render_segmentation2d(
    seconds: float,
    camera: str,
    masks: Sequence[NDArrayU8],
    class_ids: Sequence[int],
    uuids: Sequence[str | None] | None = None,
) -> None

Render 2D segmentation image.

Parameters:

  • seconds
    (float) –

    Timestamp in [sec].

  • camera
    (str) –

    Name of camera channel.

  • masks
    (Sequence[NDArrayU8]) –

    Sequence of segmentation mask of each instance, each mask is the shape of (W, H).

  • class_ids
    (Sequence[int]) –

    Sequence of label ids.

  • uuids
    (Sequence[str | None] | None, default: None ) –

    Sequence of each instance ID.

render_pointcloud

render_pointcloud(
    seconds: float,
    channel: str,
    pointcloud: PointCloudLike,
    color_mode: PointCloudColorMode = PointCloudColorMode.DISTANCE,
) -> None

Render pointcloud.

Parameters:

  • seconds
    (float) –

    Timestamp in [sec].

  • channel
    (str) –

    Name of the pointcloud sensor channel.

  • pointcloud
    (PointCloudLike) –

    Inherence object of PointCloud.

  • color_mode
    (PointCloudColorMode, default: DISTANCE ) –

    Color mode for pointcloud.

render_image

render_image(
    seconds: float, camera: str, image: str | NDArrayU8
) -> None

Render an image.

Parameters:

  • seconds
    (float) –

    Timestamp in [sec].

  • camera
    (str) –

    Name of the camera channel.

  • image
    (str | NDArrayU8) –

    Image tensor or path of the image file.

render_ego

render_ego(ego_pose: EgoPose) -> None
render_ego(
    seconds: float,
    translation: Vector3Like,
    rotation: RotationLike,
    geocoordinate: Vector3Like | None = None,
) -> None
render_ego(*args, **kwargs) -> None

Render an ego pose.

render_calibration

render_calibration(
    sensor: Sensor,
    calibration: CalibratedSensor,
    resolution: Vector2Like | None = None,
) -> None
render_calibration(
    channel: str,
    modality: str | SensorModality,
    translation: Vector3Like,
    rotation: RotationLike,
    camera_intrinsic: CamIntrinsicLike | None = None,
    resolution: Vector2Like | None = None,
) -> None
render_calibration(*args, **kwargs) -> None

Render a sensor calibration.

render_map

render_map(filepath: str) -> None

Render vector map.

Parameters:

  • filepath
    (str) –

    Path to OSM file.

ViewerConfig

to_blueprint

to_blueprint() -> rrb.BlueprintLike

Return the recording blueprint.

has_spatial3d

has_spatial3d() -> bool

Return True if the configuration contains 3D view space.

has_spatial2d

has_spatial2d() -> bool

Return True if the configuration contains 2D view space.

pointcloud_color

pointcloud_color(
    pointcloud: PointCloudLike,
    color_mode: PointCloudColorMode = PointCloudColorMode.DISTANCE,
) -> NDArrayF64

Return color map depending on the specified color mode.

Parameters:

  • pointcloud

    (PointCloudLike) –

    Any inheritance of PointCloud class.

  • color_mode

    (PointCloudColorMode, default: DISTANCE ) –

    Color mode for pointcloud.

calculate_geodetic_point

calculate_geodetic_point(
    position: Vector3Like, origin: Vector2Like
) -> Vector2

Transform a position in a map coordinate system to a position in a geodetic coordinate system.

Parameters:

  • position

    (Vector3Like) –

    3D position in a map coordinate system.

  • origin

    (Vector2Like) –

    Map origin position in a geodetic coordinate system, which is (latitude, longitude).

Returns:

  • Vector2

    Transformed position in a geodetic coordinate system, which is (latitude, longitude).

format_entity

format_entity(*entities: Sequence[str]) -> str

Format entity path.

Parameters:

  • *entities

    (Sequence[str], default: () ) –

    Entity path(s).

Returns:

  • str

    Formatted entity path.

Examples:

>>> format_entity("map")
"map"
>>> format_entity("map", "map/base_link")
"map/base_link"
>>> format_entity("map", "map/base_link", "camera")
"map/base_link/camera"