Skip to content

viewer

RerunViewer

RerunViewer(
    app_id: str,
    *,
    cameras: Sequence[str] | None = None,
    with_3d: bool = True,
    spawn: bool = True,
)

A viewer class that renders some components powered by rerun.

Construct a new object.

Parameters:

  • app_id

    (str) –

    Application ID.

  • cameras

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

    Sequence of camera names. If None, any 2D spaces will not be visualized.

  • with_3d

    (bool, default: True ) –

    Whether to render objects with the 3D space.

  • spawn

    (bool, default: True ) –

    Whether to spawn the viewer.

Examples:

>>> from t4_devkit.viewer import RerunViewer
# Rendering both 3D/2D spaces
>>> viewer = RerunViewer("myapp", cameras=["camera0", "camera1"])
# Rendering 3D space only
>>> viewer = RerunViewer("myapp")
# Rendering 2D space only
>>> viewer = RerunViewer("myapp", cameras=["camera0", "camera1"], with_3d=False)

with_labels

with_labels(label2id: dict[str, int]) -> Self

Return myself after creating rr.AnnotationContext on the recording.

Parameters:

  • label2id
    (dict[str, int]) –

    Key-value mapping which maps label name to its class ID.

Returns:

  • Self

    Self instance.

Examples:

>>> label2id = {"car": 0, "pedestrian": 1}
>>> viewer = RerunViewer("myapp").with_labels(label2id)

with_global_origin

with_global_origin(lat_lon: tuple[float, float]) -> Self

Return myself after setting global origin.

Parameters:

  • lat_lon
    (tuple[float, float]) –

    Global origin of map (latitude, longitude).

Returns:

  • Self

    Self instance.

Examples:

>>> lat_lon = (42.336849169438615, -71.05785369873047)
>>> viewer = RerunViewer("myapp").with_global_origin(lat_lon)

save

save(save_dir: str) -> None

Save recording result as save_dir/{app_id}.rrd.

Parameters:

  • save_dir
    (str) –

    Directory path to save the result.

render_box3ds

render_box3ds(
    seconds: float, boxes: Sequence[Box3D]
) -> None
render_box3ds(
    seconds: float,
    centers: Sequence[TranslationType],
    rotations: Sequence[RotationType],
    sizes: Sequence[SizeType],
    class_ids: Sequence[int],
    velocities: Sequence[VelocityType] | None = None,
    uuids: Sequence[str] | None | 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[RoiType],
    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
) -> None

Render pointcloud.

Parameters:

  • seconds
    (float) –

    Timestamp in [sec].

  • channel
    (str) –

    Name of the pointcloud sensor channel.

  • pointcloud
    (PointCloudLike) –

    Inherence object of 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: TranslationType,
    rotation: RotationType,
    geocoordinate: GeoCoordinateType | None = None,
) -> None
render_ego(*args, **kwargs) -> None

Render an ego pose.

render_calibration

render_calibration(
    sensor: Sensor, calibration: CalibratedSensor
) -> None
render_calibration(
    channel: str,
    modality: str | SensorModality,
    translation: TranslationType,
    rotation: RotationType,
    camera_intrinsic: CamIntrinsicType | None = None,
) -> None
render_calibration(*args, **kwargs) -> None

Render a sensor calibration.

distance_color

distance_color(
    distances: Number | ArrayLike,
    cmap: str | None = None,
    v_min: float = 3.0,
    v_max: float = 75.0,
) -> tuple[float, float, float] | NDArrayF64

Return color map depending on distance values.

Parameters:

  • distances

    (Number | ArrayLike) –

    Array of distances in the shape of (N,).

  • cmap

    (str | None, default: None ) –

    Color map name in matplotlib. If None, turbo_r will be used.

  • v_min

    (float, default: 3.0 ) –

    Min value to normalize.

  • v_max

    (float, default: 75.0 ) –

    Max value to normalize.

Returns:

  • tuple[float, float, float] | NDArrayF64

    Color map in the shape of (N,). If input type is any number, returns a color as tuple[float, float, float]. Otherwise, returns colors as NDArrayF64.

calculate_geodetic_point

calculate_geodetic_point(
    position: TranslationType, origin: tuple[float, float]
) -> tuple[float, float]

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

Parameters:

  • position

    (TranslationType) –

    3D position in a map coordinate system.

  • origin

    (tuple[float, float]) –

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

Returns:

  • tuple[float, float]

    tuple[float, float]: Transformed position in a geodetic coordinate system, which is (latitude, longitude).

format_entity

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

Format entity path.

Parameters:

  • root

    (str) –

    Root entity path.

  • *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"