ouster.sdk.viz

Module contents

Copyright (c) 2023, Ouster, Inc. All rights reserved.

This module provides OpenGL-based visualization for Ouster lidar data. It includes the PointViz renderer plus higher-level helpers such as SimpleViz and LidarFrameViz for displaying LidarFrames and range images.

Classes

Functions

ouster.sdk.viz.util

class AxisWithLabel(point_viz, *, pose=array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), label='', length=1.0, thickness=3, label_scale=1.0, axis_n=100, enabled=True)[source]

Bases: object

Coordinate axis with a text label.

Parameters:
  • point_viz (PointViz)

  • pose (ndarray)

  • label (str)

  • length (float)

  • thickness (int)

  • label_scale (float)

  • axis_n (int)

  • enabled (bool)

disable()[source]

Disable the label and remove it from the viz :rtype: None

Return type:

None

enable()[source]

Enable the label and make it added to the viz :rtype: None

Return type:

None

property enabled: bool

True if label is added to the viz

property label: str

Label text, 4x4 matrix

property pose: ndarray

Label pose, 4x4 matrix

toggle()[source]

Toggle the label visibility (i.e. presence in the viz) :rtype: bool

Return type:

bool

update()[source]

Update label component viz states. :rtype: None

Return type:

None

Camera

class Camera

Controls the camera view and projection.

__copy__(self) ouster.sdk.viz.Camera
__deepcopy__(self, arg: object, /) ouster.sdk.viz.Camera
__init__(*args, **kwargs)
__module__ = 'ouster.sdk.viz'
__new__(**kwargs)
dolly(self, amount: float) None

Move the camera towards or away from the target.

dolly_xy(self, x: float, y: float) None

Move the camera in the XY plane of the camera view.

Parameters:
  • x (float) – horizontal offset

  • y (float) – vertical offset

get_dolly(self) float

Get the dolly (i.e. log distance) of the camera from the target.

get_fov(self) float

Get the diagonal field of view in degrees.

get_pitch(self) float

Get pitch in degrees.

get_proj_offset(self) list[float]

Get the 2d position of a camera target in the viewport.

get_roll(self) float

Get roll in degrees.

get_target(self) numpy.ndarray[dtype=float64, shape=(4, 4), order='C']

Get a pose of the camera target.

get_view_offset(self) list[float]

Get view offset of a camera

get_yaw(self) float

Get yaw in degrees.

is_orthographic(self) bool

Get the orthographic state.

pitch(self, degrees: float) None

Pitch the camera up or down.

reset(self) None

Reset the camera view and fov.

roll(self, degrees: float) None

Roll the camera left or right about the camera target.

set_dolly(self, log_distance: float) None

Set the dolly (i.e. log distance) of the camera from the target.

set_fov(self, degrees: float) None

Set the diagonal field of view.

set_orthographic(self, state: bool) None

Use an orthographic or perspective projection.

set_pitch(self, degrees: float) None

Set pitch in degrees.

set_proj_offset(self, x: float, y: float) None

Set the 2d position of camera target in the viewport.

Parameters:
  • x (float) – horizontal position in in normalized coordinates [-1, 1]

  • y (float) – vertical position in in normalized coordinates [-1, 1]

set_roll(self, degrees: float) None

Set roll in degrees.

set_target(self, pose: ndarray[dtype=float64, shape=(*, *), order='C', device='cpu', writable=False]) None

Set the camera target pose (inverted pose).

Parameters:

pose (Annotated[NDArray[numpy.float64], dict(shape=(None, None), order='C', device='cpu', writable=False)]) – 4x4 homogeneous transformation matrix (row-major/C-order)

set_view_offset(self, view_offset: collections.abc.Sequence[float]) None

Set view offset of a camera

set_yaw(self, degrees: float) None

Set yaw in degrees.

yaw(self, degrees: float) None

Orbit the camera left or right about the camera target.

Cloud

class Cloud(self, num_points: int)
class Cloud(self, num_points: int, extrinsics: ndarray[dtype=float64, shape=(*, *), order='C', device='cpu', writable=False])
class Cloud(self, metadata: ouster.sdk.core.SensorInfo)
class Cloud(self, xyzlut: ouster.sdk.core.XYZLut)

Manages the state of a point cloud.

Each point cloud consists of n points with w poses. The ith point will be transformed by the (i % w)th pose. For example for 2048 x 64 Ouster lidar point cloud, we may have w = 2048 poses and n = 2048 * 64 = 131072 points.

We also keep track of a per-cloud pose to efficiently transform the whole point cloud without having to update all ~2048 poses.

Overloaded function.

  1. __init__(self, num_points: int) -> None

    def __init__(self, n_points: int, extrinsics: np.ndarray) -> None:

    Unstructured point cloud for visualization.

    Call set_xyz() to update

    Args:

    num_points: number of points

  2. __init__(self, num_points: int, extrinsics: ndarray[dtype=float64, shape=(*, *), order='C', device='cpu', writable=False]) -> None

    def __init__(self, n_points: int, extrinsics: np.ndarray) -> None:

    Unstructured point cloud for visualization.

    Call set_xyz() to update

    Args:

    num_points: number of points extrinsics: sensor extrinsic calibration. 4x4 row-major

    homogeneous transformation matrix.

  3. __init__(self, metadata: ouster.sdk.core.SensorInfo) -> None

    def __init__(self, si: SensorInfo) -> None:

    Structured point cloud for visualization.

    Call set_range() to update

    Args:

    info: sensor metadata

  4. __init__(self, xyzlut: ouster.sdk.core.XYZLut) -> None

    def __init__(self, xyzlut: XYZLut) -> None:

    Structured point cloud for visualization.

    Call set_range() to update

    Args:

    xyzlut: sensor XYZLut

__annotations__ = {'cols': 'int', 'selectable': 'bool', 'size': 'int'}
__copy__(self) ouster.sdk.viz.Cloud
__deepcopy__(self, arg: object, /) ouster.sdk.viz.Cloud
__init__(self, num_points: int) None
__init__(self, num_points: int, extrinsics: ndarray[dtype=float64, shape=(*, *), order='C', device='cpu', writable=False]) None
__init__(self, metadata: ouster.sdk.core.SensorInfo) None
__init__(self, xyzlut: ouster.sdk.core.XYZLut) None

Overloaded function.

  1. __init__(self, num_points: int) -> None

    def __init__(self, n_points: int, extrinsics: np.ndarray) -> None:

    Unstructured point cloud for visualization.

    Call set_xyz() to update

    Args:

    num_points (int): number of points

  2. __init__(self, num_points: int, extrinsics: ndarray[dtype=float64, shape=(*, *), order='C', device='cpu', writable=False]) -> None

    def __init__(self, n_points: int, extrinsics: np.ndarray) -> None:

    Unstructured point cloud for visualization.

    Call set_xyz() to update

    Args:

    num_points (int): number of points extrinsics (Annotated[NDArray[numpy.float64], dict(shape=(None, None), order=’C’, device=’cpu’, writable=False)]): sensor extrinsic calibration. 4x4 row-major

    homogeneous transformation matrix.

  3. __init__(self, metadata: ouster.sdk.core.SensorInfo) -> None

    def __init__(self, si: SensorInfo) -> None:

    Structured point cloud for visualization.

    Call set_range() to update

    Args:

    info: sensor metadata

  4. __init__(self, xyzlut: ouster.sdk.core.XYZLut) -> None

    def __init__(self, xyzlut: XYZLut) -> None:

    Structured point cloud for visualization.

    Call set_range() to update

    Args:

    xyzlut (ouster.sdk.core.XYZLut): sensor XYZLut

__module__ = 'ouster.sdk.viz'
__new__(**kwargs)
__repr__(self) str
clear_on_select(self) None

Clears the on select callback and makes this cloud no longer selectable.

property cols: int

Number of columns in a cloud (1 if point cloud is unstructured

property selectable: bool

If the cloud is selectable or not.

set_column_poses(self, column_poses: ndarray[writable=False]) None

Set frame poses (per every column).

Parameters:

column_poses (Annotated[NDArray, dict(writable=False)]) – array of poses (Wx4x4) per every column.

set_key(self, key: ndarray[writable=False]) None

Set the key values, used for colouring.

Number of elements defines the type of Cloud coloration: - num elements == cloud.get_size(): MONO with palette - 3 dimensions with the last dimesion: 3 - RGB, 4 - RGBA,

no palette used

Parameters:

key (Annotated[NDArray, dict(writable=False)]) –

uint8 or float32, or float64 array of at least as many elements as there are points, preferably normalized between 0 and 1

(float) or between 0 and 255 (uint8)

set_mask(self, mask: ndarray[writable=False]) None

Set the RGBA mask values, used as an overlay on top of the key.

Parameters:

mask (Annotated[NDArray, dict(writable=False)]) – uint8, float32, or float64 array of at least 4x as many elements as there are points, preferably normalized between 0 and 1 (float) or between 0 and 255 (uint8)

set_on_select(self, arg: object, /) None

Makes the cloud selectable and adds a callback called on selection.

set_palette(self, palette: ndarray[shape=(*, 3), writable=False]) None

Set the point cloud color palette.

Parameters:

palette (Annotated[NDArray, dict(shape=(None, 3), writable=False)]) – the new palette to use, must have size 3*palette_size

set_point_size(self, size: float) None

Set point size.

Parameters:

size (float) – point size

set_pose(self, pose: numpy.ndarray) None

Set the ith point cloud pose.

Parameters:

pose (numpy.ndarray) – 4x4 homogeneous transformation matrix (row-major/C-order)

set_range(self, range: ndarray[shape=(*, *), writable=False]) None

Set the range values.

Parameters:

range (Annotated[NDArray, dict(shape=(None, None), writable=False)]) – array of at least as many elements as there are points, representing the range of the points

set_xyz(self, xyz: ndarray[writable=False]) None

Set the XYZ values.

Parameters:

xyz (array of np.float32) –

Supports 3 formats: * array of exactly 3n where n is the number of

points, so that the xyz position of the ith point is i, i+n, i+2n.

  • array of (N, 3) where N is the number of points

  • array of (H, W, 3) where H*W is the number of points

property size: int

Number of points in a cloud

ouster.sdk.viz.view_mode

class CloudMode(*args, **kwargs)[source]

Bases: FieldViewMode, Protocol

Applies the view mode key to the viz.Cloud

set_cloud_color(cloud, ls, *, return_num=0)[source]

Prepares the key data and sets the cloud key to it. :rtype: None

Parameters:
Return type:

None

class CloudPaletteItem(name, palette)[source]

Bases: object

Palette with a name

Parameters:
  • name (str)

  • palette (ndarray)

name: str
palette: ndarray
class FieldViewMode(*args, **kwargs)[source]

Bases: Protocol

LidarFrame field processor

View modes define the process of getting the key data for the frame and return number as well as checks the possibility of showing data in that mode, see enabled().

enabled(ls, return_num=0)[source]

Checks the view mode availability for a frame and return number :rtype: bool

Parameters:
Return type:

bool

property name: str

Name of the view mode

property names: List[str]

Name of the view mode per return number

class HDRRGBMode(field, info)[source]

Bases: ImageCloudMode

RGB view mode using LocalToneMapper.

Parameters:
enabled(ls, return_num=0)[source]

Checks the view mode availability for a frame and return number :rtype: bool

Parameters:
Return type:

bool

property name: str

Name of the view mode

property names: List[str]

Name of the view mode per return number

set_cloud_color(cloud, ls, return_num=0)[source]

Prepares the key data and sets the cloud key to it. :rtype: None

Parameters:
Return type:

None

set_image(img, ls, return_num=0)[source]

Prepares the key data and sets the image key to it. :rtype: None

Parameters:
Return type:

None

class ImageCloudMode(*args, **kwargs)[source]

Bases: ImageMode, CloudMode, Protocol

Applies the view mode to viz.Cloud and viz.Image

class ImageMode(*args, **kwargs)[source]

Bases: FieldViewMode, Protocol

Applies the view mode key to the viz.Image

set_image(img, ls, return_num=0)[source]

Prepares the key data and sets the image key to it. :rtype: None

Parameters:
Return type:

None

LidarFrameVizMode

Field view mode types

alias of ImageCloudMode | ImageMode | CloudMode

class NormalsMode(field, *, info=None)[source]

Bases: ImageCloudMode

Normals value remap [-1, 1] -> [0, 1]

Parameters:
enabled(ls, return_num=0)[source]

Checks the view mode availability for a frame and return number

Parameters:
property name: str

Name of the view mode

property names: List[str]

Name of the view mode per return number

set_cloud_color(cloud, ls, return_num=0)[source]

Prepares the key data and sets the cloud key to it. :rtype: None

Parameters:
Return type:

None

set_image(img, ls, return_num=0)[source]

Prepares the key data and sets the image key to it. :rtype: None

Parameters:
Return type:

None

class RGBMode(field, *, info=None)[source]

Bases: ImageCloudMode

RGB view mode

Parameters:
  • info (Optional[SensorInfo]) – sensor metadata used mainly for destaggering here

  • field (str) – channel field to process

enabled(ls, return_num=0)[source]

Checks the view mode availability for a frame and return number

Parameters:
property name: str

Name of the view mode

property names: List[str]

Name of the view mode per return number

set_cloud_color(cloud, ls, return_num=0)[source]

Prepares the key data and sets the cloud key to it. :rtype: None

Parameters:
Return type:

None

set_image(img, ls, return_num=0)[source]

Prepares the key data and sets the image key to it. :rtype: None

Parameters:
Return type:

None

class ReflMode(*, info=None)[source]

Bases: SimpleMode, ImageCloudMode

Prepares image/cloud data for REFLECTIVITY channel

Parameters:
  • info (Optional[SensorInfo]) – sensor metadata used mainly for destaggering here

  • field – name of field to process, second return is handled automatically

  • prefix – name prefix

  • suffix – name suffix

  • use_ae – if True, use AutoExposure for the field

  • use_buc – if True, use BeamUniformityCorrector for the field

  • scale – if use_ae is false and this is set, use this to scale the values for display

class RingMode(info)[source]

Bases: CloudMode

View mode to show laser ring.

Parameters:

info (SensorInfo) – sensor metadata

enabled(ls, return_num=0)[source]

Checks the view mode availability for a frame and return number

Parameters:
property name: str

Name of the view mode

property names: List[str]

Name of the view mode per return number

set_cloud_color(cloud, ls, return_num=0)[source]

Prepares the key data and sets the cloud key to it. :rtype: None

Parameters:
Return type:

None

class SensorMode(info, color)[source]

Bases: CloudMode

View mode to show sensor index.

Parameters:
  • info (SensorInfo) – sensor metadata

  • color (Tuple[int, int, int])

enabled(ls, return_num=0)[source]

Checks the view mode availability for a frame and return number

Parameters:
property name: str

Name of the view mode

property names: List[str]

Name of the view mode per return number

set_cloud_color(cloud, ls, return_num=0)[source]

Prepares the key data and sets the cloud key to it. :rtype: None

Parameters:
Return type:

None

class SimpleMode(field, *, info=None, prefix='', suffix='', use_ae=True, use_buc=False, scale=None)[source]

Bases: ImageCloudMode

Basic view mode with AutoExposure and BeamUniformityCorrector

Handles single and dual returns frames.

When AutoExposure is enabled its state updates only for return_num=0 but applies for both returns.

Parameters:
  • info (Optional[SensorInfo]) – sensor metadata used mainly for destaggering here

  • field (str) – name of field to process, second return is handled automatically

  • prefix (Optional[str]) – name prefix

  • suffix (Optional[str]) – name suffix

  • use_ae (bool) – if True, use AutoExposure for the field

  • use_buc (bool) – if True, use BeamUniformityCorrector for the field

  • scale (Optional[float]) – if use_ae is false and this is set, use this to scale the values for display

enabled(ls, return_num=0)[source]

Checks the view mode availability for a frame and return number

Parameters:
property name: str

Name of the view mode

property names: List[str]

Name of the view mode per return number

set_cloud_color(cloud, ls, return_num=0)[source]

Prepares the key data and sets the cloud key to it. :rtype: None

Parameters:
Return type:

None

set_image(img, ls, return_num=0)[source]

Prepares the key data and sets the image key to it. :rtype: None

Parameters:
Return type:

None

class TimestampMode(info)[source]

Bases: CloudMode

View mode to show column timestamp.

Parameters:

info (SensorInfo) – sensor metadata

enabled(ls, return_num=0)[source]

Checks the view mode availability for a frame and return number

Parameters:
property name: str

Name of the view mode

property names: List[str]

Name of the view mode per return number

set_cloud_color(cloud, ls, return_num=0)[source]

Prepares the key data and sets the cloud key to it. :rtype: None

Parameters:
Return type:

None

is_norm_reflectivity_mode(mode)[source]

Checks whether the image/cloud mode is a normalized REFLECTIVITY mode

Return type:

bool

Parameters:

mode (FieldViewMode)

ouster.sdk.viz.core

Copyright (c) 2021, Ouster, Inc. All rights reserved.

Sensor data visualization tools.

Visualize lidar data using OpenGL.

class ImuVisualizationConfig(options='only_gyro')[source]

Bases: object

downsample_factor = 2
field_colors = {'IMU_ACC': (1.0, 0.0, 0.0, 1.0), 'IMU_GYRO': (1.0, 1.0, 1.0, 1.0)}
imu_plot_height_pixels = 28
imu_plot_width_pixels = 1000
class LidarFrameViz(metas, point_viz=None, accumulators_config=None, imu_viz_config=<ouster.sdk.viz.core.ImuVisualizationConfig object>, *, _img_aspect_ratio=0, _buflen=50, _add_default_controls=True)[source]

Bases: object

Multi LidarFrame clouds visualizer

Uses the supplied PointViz instance to easily display the contents of a LidarFrame. Sets up key bindings to toggle which channel fields and returns are displayed, and change 2D image and point size.

Parameters:
class CameraMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

FIXED = 2
FOLLOW = 0
FOLLOW_ROTATION_LOCKED = 1
FOLLOW_SMOOTH = 3
FOLLOW_SMOOTH_ROTATION_LOCK = 4
class FlagsMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

HIDE_BLOOM = 3
HIGHLIGHT_BLOOM = 2
HIGHLIGHT_OBJECTS = 5
HIGHLIGHT_SECOND = 1
HIGHLIGHT_ZONES = 4
NONE = 0
class FlagsPalette(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

DISTINCT = 1
RAINBOW = 0
class ImageViewMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

ALL = 0
ALL_FLIPPED = 1
ONE = 2
ONE_FLIPPED = 3
class ImagesLayout(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

HORIZONTAL = 0
VERTICAL = 1
MAX_SENSOR_TOGGLE_KEYS = 9
class OsdState(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

DEFAULT = (2,)
HELP = 3
NONE = (1,)
class TrackViewMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

OFF = 0
TRACK_ONLY = 1
TRACK_PLUS_PER_FRAME_TRAJECTORY = 2
cicle_ring_line_width()[source]

Change rings line width. :rtype: None

Return type:

None

clear_pose_histories()[source]

Clear frame/camera pose histories used for interpolation. :rtype: None

Return type:

None

clear_trajectory()[source]
Return type:

None

cycle_camera_mode(direction=1)[source]

Toggle the camera follow mode. :rtype: None

Parameters:

direction (int)

Return type:

None

cycle_cloud_mode(direction=1)[source]

Change the coloring mode of the 3D point cloud. :rtype: None

Parameters:

direction (int)

Return type:

None

cycle_cloud_palette(*, direction=1)[source]

Change the color palette of the 3D point cloud. :rtype: None

Parameters:

direction (int)

Return type:

None

cycle_flags_palette()[source]

Cycle the palette used for flags modes. :rtype: None

Return type:

None

cycle_img_mode(i, *, direction=1)[source]

Change the displayed field of the i’th image. :rtype: None

Parameters:
  • i (int)

  • direction (int)

Return type:

None

cycle_img_view_mode()[source]
Return type:

None

cycle_object_color_mode()[source]

Cycle the mode used for object highlighting. :rtype: None

Return type:

None

cycle_object_view_mode()[source]
Return type:

None

cycle_osd_scale()[source]
cycle_zone_render_mode()[source]
Return type:

None

cycle_zone_selection_mode()[source]
Return type:

None

draw(update=True, update_camera=True)[source]

Process and draw the latest state to the screen. :rtype: None

Parameters:
  • update (bool)

  • update_camera (bool)

Return type:

None

property frame: FrameSet

The currently displayed frame.

property frame_num: int

The currently displayed frame number

hide_all_imu_plots()[source]
hide_all_sensor_labels()[source]
imu_plot(frames, imu_viz_config)[source]
property metadata: List[SensorInfo]

Metadatas for the displayed sensors.

property osd_state: OsdState

Returns the state of the on screen display.

print_key_bindings()[source]
Return type:

None

run()[source]

Run the rendering loop of the visualizer.

See PointViz.run() :rtype: None

Return type:

None

select_cloud_mode(mode)[source]

Change the coloring mode of the 3D point cloud. :rtype: bool

Parameters:

mode (str)

Return type:

bool

select_img_mode(i, mode)[source]

Change the displayed field of the i’th image. :rtype: bool

Parameters:
  • i (int)

  • mode (str)

Return type:

bool

set_class_maps(class_maps)[source]

Set the class maps for the visualizer. :rtype: None

Parameters:

class_maps (ClassMapSet)

Return type:

None

set_interpolant(interpolant)[source]
Return type:

None

Parameters:

interpolant (float)

set_view(view)[source]
Parameters:

view (str)

set_zone_selection_and_render_modes(sel_mode, render_mode)[source]
Return type:

None

Parameters:
show_all_imu_plots()[source]
show_all_sensor_labels()[source]
text_scale()[source]
toggle_axis_markers()[source]

Toggle the helper axis of a frame ON/OFF :rtype: None

Return type:

None

toggle_cloud(i)[source]

Toggle whether the i’th return is displayed. :rtype: None

Parameters:

i (int)

Return type:

None

toggle_flip_images()[source]

Toggle if 2D images should be flipped or not. :rtype: None

Return type:

None

toggle_help()[source]
Return type:

None

toggle_osd(state=None)[source]

Show or hide the on-screen display. :rtype: None

Parameters:

state (bool | None)

Return type:

None

toggle_sensor(sensor_index)[source]

Toggle whether the i’th sensor data is displayed. :rtype: None

Parameters:

sensor_index (int)

Return type:

None

toggle_sky()[source]

Toggle showing the color the sky in the pointcloud where there is no return :rtype: None

Return type:

None

toggle_track_view_mode()[source]

Cycle through the track view modes :rtype: None

Return type:

None

update(frames, frame_num=None, last_n_frame_sets=[])[source]

Update the LidarFrameViz state with the provided frames. :rtype: None

Parameters:
Return type:

None

update_flags_mode(mode=None, direction=1)[source]
Return type:

None

Parameters:
update_image_size(amount)[source]

Change the size of the 2D image and position image labels. :rtype: None

Parameters:

amount (int)

Return type:

None

update_point_size(amount)[source]

Change the point size of the 3D cloud. :rtype: None

Parameters:

amount (int)

Return type:

None

update_ring_size(amount)[source]

Change distance ring size. :rtype: None

Parameters:

amount (int)

Return type:

None

class LiveConsumer(iterable, should_count_dropped_frame_method)[source]

Bases: object

Spawns a thread to consume frames as soon as they’re available. This is a work-around to deal with situations where the visualizer is too slow to keep up with a live sensor.

property dropped_frames
shutdown()[source]
start()[source]
class SimpleViz(metadata, *, rate=None, pause_at=-1, on_eof='exit', accum_max_num=0, accum_min_dist_meters=0, accum_min_dist_num=1, map_enabled=False, map_select_ratio=0.001, map_max_points=1500000, imu_viz_config=<ouster.sdk.viz.core.ImuVisualizationConfig object>, title='Ouster Viz', maximized=False, fullscreen=False, resolution=None, screenshot_resolution=None, _override_pointviz=None, _override_lidar_frame_viz=None, _buflen=50, video_format='png', clear_on_loop=False, subframes=0)[source]

Bases: object

Visualize a stream of LidarFrames.

Handles controls for playback speed, pausing and stepping.

Parameters:
  • arg – Metadata associated with the frames to be visualized or a LidarFrameViz instance to use.

  • rate (Optional[float]) – Playback rate. One of 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0 or None for “live” playback (the default).

  • pause_at (int) – frame number to pause at, default (-1) - no auto pause, to stop after the very first frame use 0

  • on_eof (str) – What to do when the source ends. One of ‘exit’, ‘stop’ or ‘loop’

  • video_format (str) – Format for saving continuous screenshots. One of ‘png’ or ‘gif’

  • metadata (List[SensorInfo] | SensorInfo)

  • accum_max_num (int)

  • accum_min_dist_meters (float)

  • accum_min_dist_num (int)

  • map_enabled (bool)

  • map_select_ratio (float)

  • map_max_points (int)

  • imu_viz_config (ImuVisualizationConfig)

  • title (str)

  • maximized (bool)

  • fullscreen (bool)

  • resolution (Tuple[int, int] | None)

  • screenshot_resolution (Tuple[int, int] | float | None)

  • _override_pointviz (PointViz | None)

  • _override_lidar_frame_viz (LidarFrameViz | None)

  • _buflen (int)

  • clear_on_loop (bool)

Raises:

ValueError – if the specified rate isn’t one of the options

adjust_subframes(direction)[source]
Parameters:

direction (int)

cycle_screenshot_res_factor(direction)[source]
Parameters:

direction (int)

property frames_per_sec: float

Frames per second processing rate.

modify_rate(amount)[source]

Switch between preset playback rates. :rtype: None

Parameters:

amount (int)

Return type:

None

run(frames)[source]

Start reading frames and visualizing the stream.

Must be called from the main thread on macOS. Will close the provided frame source before returning.

Parameters:

frames (Union[Iterable[FrameSet], Iterable[LidarFrame], Iterable[List[Optional[LidarFrame]]]]) – A stream of frames to visualize.

Return type:

None

Returns:

When the stream is consumed or the visualizer window is closed.

property scans_per_sec: float

use frames_per_sec.

Type:

Deprecated

screenshot(file_path=None)[source]
Return type:

None

Parameters:

file_path (str | None)

seek_relative(n_frames)[source]

Seek forward of backwards in the stream. :rtype: None

Parameters:

n_frames (int)

Return type:

None

set_class_maps(class_maps)[source]

Set the class maps for the visualizer. :rtype: None

Parameters:

class_maps (ClassMapSet)

Return type:

None

toggle_help()[source]
Return type:

None

toggle_img_recording()[source]
Return type:

None

toggle_osd(state=None)[source]

Show or hide the on-screen display. :rtype: None

Parameters:

state (bool | None)

Return type:

None

toggle_pause()[source]

Pause or unpause the visualization. :rtype: None

Return type:

None

toggle_video_format()[source]
Return type:

None

lf_show(frames, *, title=None)[source]

[BETA] Display a set of LidarFrames in an interactive window.

Parameters:
Return type:

None

Optional Args:
title: Title of the visualization window. If not provided,

it will be composed from the sensor serial numbers.

Note

This is a beta feature and its API may change in future releases.

Cuboid

class Cuboid(self, pose: ndarray[dtype=float64, shape=(*, *), order='C', device='cpu', writable=False], rgba: tuple)

Manages the state of a single cuboid.

Creates cuboid.

Parameters:
  • pose – 4x4 pose matrix

  • rgba – 4 value tuple of RGBA color

__annotations__ = {'selectable': 'bool'}
__copy__(self) ouster.sdk.viz.Cuboid
__deepcopy__(self, arg: object, /) ouster.sdk.viz.Cuboid
__init__(self, pose: ndarray[dtype=float64, shape=(*, *), order='C', device='cpu', writable=False], rgba: tuple) None

Creates cuboid.

Parameters:
  • pose (Annotated[NDArray[numpy.float64], dict(shape=(None, None), order='C', device='cpu', writable=False)]) – 4x4 pose matrix

  • rgba (tuple) – 4 value tuple of RGBA color

__module__ = 'ouster.sdk.viz'
__new__(**kwargs)
clear_on_select(self) None

Clears the on select callback and makes this cuboid no longer selectable.

from_object = <nanobind.nb_func object>
property selectable: bool

If the cuboid is selectable or not.

set_on_select(self, arg: object, /) None

Makes the cuboid selectable and adds a callback called on selection.

set_rgba(self, rgba: tuple) None

Set the color of the cuboid.

Parameters:

rgba (tuple) – 4 value tuple of RGBA color

set_transform(self, pose: ndarray[dtype=float64, shape=(*, *), order='C', device='cpu', writable=False]) None

Set the transform defining the cuboid.

Applied to a unit cube centered at the origin.

Parameters:

pose (Annotated[NDArray[numpy.float64], dict(shape=(None, None), order='C', device='cpu', writable=False)]) – 4x4 pose matrix

EventModifierKeys

class EventModifierKeys(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
__format__(format_spec, /)

Convert to a string according to format_spec.

__str__()

Return repr(self).

__repr__()

Return repr(self).

__or__(other)

Return self|value.

__and__(other)

Return self&value.

__xor__(other)

Return self^value.

__ror__(other)

Return value|self.

__rand__(other)

Return value&self.

__rxor__(other)

Return value^self.

__invert__()

~self

__new__(value)
__nb_enum__ = <capsule object NULL>
MOD_NONE = 0
MOD_SHIFT = 1
MOD_CONTROL = 2
MOD_ALT = 4
MOD_SUPER = 8
MOD_CAPS_LOCK = 16
MOD_NUM_LOCK = 32
__module__ = 'ouster.sdk.viz'

Image

class Image(self)

Manages the state of an image.

__copy__(self) ouster.sdk.viz.Image
__deepcopy__(self, arg: object, /) ouster.sdk.viz.Image
__init__(self) None
__module__ = 'ouster.sdk.viz'
__new__(**kwargs)
clear_palette(self) None

Removes the image palette and use keys as grey color in MONO

image_pixel_to_viewport_coordinates(self, arg0: ouster.sdk.viz.WindowCtx, arg1: tuple[int, int], /) tuple[float, float]

Returns the window pixel (x, y) given an image (row, col) pixel.

pixel_size(self, arg: ouster.sdk.viz.WindowCtx, /) tuple[float, float]

Returns the pixel size (w, h) in window pixels.

set_hshift(self, hshift: float) None

Set horizontal shift in normalized viewport screen width coordinate.

This may be used to “snap” images to the left/right screen edges.

Some example values:

0 - default, image is centered horizontally on the screen -0.5 - image moved to the left for the 1/4 of a horizontal viewport -1 - image moved to the left for the 1/2 of a horizontal viewport +1 - image moved to the right for the 1/2 of a horizontal viewport +0.5 - image moved to the right for the 1/4 of a horizontal viewport

set_image(self, image: numpy.ndarray) None

Set the image data, MONO or RGB/RGBA depending on dimensions.

Color palette is applied for MONO mode if set_palette() was used to set the palette, otherwise MONO mode makes the monochrome image.

Parameters:

image (numpy.ndarray) – uint8, float32, or float64 2D array for a monochrome image or 3D array with RGB or RGBA components for color image.

set_mask(self, mask: ndarray[shape=(*, *, 4), writable=False]) None

Set the RGBA mask.

Parameters:

mask (Annotated[NDArray, dict(shape=(None, None, 4), writable=False)]) – uint8, float32, or float64 M x N x 4 array with RGBA mask

set_palette(self, palette: ndarray[shape=(*, 3), writable=False]) None

Set the image color palette.

Parameters:

palette (Annotated[NDArray, dict(shape=(None, 3), writable=False)]) – the new palette to use, must have size 3*palette_size

set_position(self, x_min: float, x_max: float, y_min: float, y_max: float) None

Set the display position of the image.

Coordinates are {x_min, x_max, y_max, y_min} in sort-of normalized screen coordinates: y is in [-1, 1], and x uses the same scale (i.e. window width is ignored). This is currently just the same method the previous hard-coded ‘image_frac’ logic was using; I believe it was done this way to allow scaling with the window while maintaining the aspect ratio.

Parameters:
  • x_min (float) – min x

  • x_max (float) – max x

  • y_min (float) – min y

  • y_max (float) – max y

viewport_coordinates_to_image_pixel(self, arg0: ouster.sdk.viz.WindowCtx, arg1: float, arg2: float, /) tuple[int, int]
Returns the image pixel as a (row, col) tuple given window coordinates,

or None if the given window coordinate is not within the image.

Label

class Label(self, text: str, x: float, y: float, z: float)
class Label(self, text: str, x: float, y: float, align_right: bool = False, align_top: bool = False)

Manages the state of a text label.

Overloaded function.

  1. __init__(self, text: str, x: float, y: float, z: float) -> None

    def __init__(self, text: str, x: float, y: float, z: float) -> None:

    Creates 3D Label.

    Args:

    text: label text x,y,z: label location

  2. __init__(self, text: str, x: float, y: float, align_right: bool = False, align_top: bool = False) -> None

    def __init__(self, text: str, x: float, y: float, align_right: bool = ..., align_top: bool = ...) -> None:

    Creates 2D Label.

    Args:

    text: label text x,y: label 2D location in screen coords [0..1], corresponding to top left corner of label align_right: if True - anchor point of the label is the right side align_top: if True - anchor point of the label is the top side

__annotations__ = {'text_height': 'float'}
__copy__(self) ouster.sdk.viz.Label
__deepcopy__(self, arg: object, /) ouster.sdk.viz.Label
__init__(self, text: str, x: float, y: float, z: float) None
__init__(self, text: str, x: float, y: float, align_right: bool = False, align_top: bool = False) None

Overloaded function.

  1. __init__(self, text: str, x: float, y: float, z: float) -> None

    def __init__(self, text: str, x: float, y: float, z: float) -> None:

    Creates 3D Label.

    Args:

    text (str): label text x,y,z: label location

  2. __init__(self, text: str, x: float, y: float, align_right: bool = False, align_top: bool = False) -> None

    def __init__(self, text: str, x: float, y: float, align_right: bool = ..., align_top: bool = ...) -> None:

    Creates 2D Label.

    Args:

    text (str): label text x,y: label 2D location in screen coords [0..1], corresponding to top left corner of label align_right (bool): if True - anchor point of the label is the right side align_top (bool): if True - anchor point of the label is the top side

__module__ = 'ouster.sdk.viz'
__new__(**kwargs)
set_position(self, x: float, y: float, z: float) None
set_position(self, x: float, y: float, align_right: bool = False, align_top: bool = False) None

Overloaded function.

  1. set_position(self, x: float, y: float, z: float) -> None

    def set_position(self, x: float, y: float, z: float) -> None:

    Set label position. Position correspnods to top left (viewer’s left) of label.

    Args:

    x,y,z: label position in 3D

  2. set_position(self, x: float, y: float, align_right: bool = False, align_top: bool = False) -> None

    def set_position(self, x: float, y: float, align_right: bool = ...) -> None:

    Set position of the 2D label.

    Args:

    x,y: label 2D position in screen coords [0..1] align_right (bool): if True - anchor point of the label is the right side align_top (bool): if True - anchor point of the label is the top side

set_rgba(self, rgba: tuple) None

Set the color of the label.

Parameters:

rgba (tuple) – 4 value tuple of RGBA color

set_scale(self, scale: float) None

Set scaling factor of the label.

Parameters:

scale (float) – text scale factor

set_text(self, text: str) None

Update label text.

Parameters:

text (str) – new text to display

property text_height: float

Get the height of the label text.

ouster.sdk.viz.accumulators

Copyright (c) 2023, Ouster, Inc. All rights reserved.

Ouster frame accumulation for LidarFrameViz

class LidarFrameVizAccumulators(model, point_viz, config, lock)[source]

Bases: object

Accumulate frames, track poses and overall map view Every new frame (LidarFrame or FrameSet) is passed through update(frame, num).

Available visualization depends on whether poses are present or not and params set on init. View modes are combination of:

  • TRACK - frame poses (i.e. trajectories) of every frame “seen” (poses required)

  • ACCUM - set of accumulated frames (key frames) picked according to params

  • MAP - overall map with select ratio of random points from every frame passed through update()

Parameters:
  • model (LidarFrameVizModel) – a LidarFrameVizModel instance.

  • point_viz (PointViz) – the PointViz instance to use for rendering clouds.

  • config (LidarFrameVizAccumulatorsConfig) –

    a LidarFrameVizAccumulatorsConfig that accepts the following keyword args: accum_max_num: aka, --accum-num, the maximum number of accumulated

    (ACCUM) frames to keep

    accum_min_dist_meters: aka, --accum-every-m, the minimum distance

    between accumulated (ACCUM) key frames

    accum_min_dist_num: aka, --accum-every, the minimum distance in

    frames between accumulated (ACCUM) key frames

    map_enabled: enable overall map accumulation (MAP) (--map) map_select_ratio: percent of points to select from the frames to the

    overall map (MAP), default 0.001

    map_max_points: maximum number of points to keep in overall map (MAP) map_overflow_from_start: if True, on map overflow continue writing

    points from the beginning (as in ring buffer), if False, overwrite points randomly in the existing map

  • lock (RLock)

clear_track()[source]
Return type:

None

cycle_cloud_mode(direction)[source]
Return type:

bool

cycle_cloud_palette(direction)[source]
Return type:

bool

draw(update=True)[source]

Process and draw the latest state to the screen. :rtype: None

Parameters:

update (bool)

Return type:

None

osd_text()[source]

Prepare OSD text for use in draw_osd or elsewhere. :rtype: str

Return type:

str

toggle_mode_accum(state=None)[source]

Toggle ACCUM view :rtype: bool

Parameters:

state (bool | None)

Return type:

bool

toggle_mode_map(state=None)[source]

Toggle MAP view :rtype: bool

Parameters:

state (bool | None)

Return type:

bool

toggle_mode_track(state=None)[source]
Return type:

bool

Parameters:

state (bool | None)

toggle_osd(state=None)[source]

Show or hide the on-screen display. :rtype: bool

Parameters:

state (bool | None)

Return type:

bool

toggle_sensor(sensor_idx, state)[source]
Parameters:

state (bool)

property track_accumulator: TracksAccumulator

Get the TracksAccumulator instance.

update(frames, frame_num=None)[source]

Updates the accumulation state from the current frame. Locking is necessary here because the accumulation state depends on the current view mode, which might change in a separate thread than the thread that calls update(). :rtype: None

Parameters:
  • frames (FrameSet)

  • frame_num (int | None)

Return type:

None

update_point_size(amount)[source]

Change the point size of the MAP/ACCUM point cloud. :rtype: bool

Parameters:

amount (int)

Return type:

bool

Lines

class Lines(self, pose: ndarray[dtype=float64, shape=(*, *), order='C', device='cpu', writable=False], rgba: tuple)

Manages the state of line segments.

Creates lines.

Parameters:
  • pose – 4x4 pose matrix

  • rgba – 4 value tuple of RGBA color

__copy__(self) ouster.sdk.viz.Lines
__deepcopy__(self, arg: object, /) ouster.sdk.viz.Lines
__init__(self, pose: ndarray[dtype=float64, shape=(*, *), order='C', device='cpu', writable=False], rgba: tuple) None

Creates lines.

Parameters:
  • pose (Annotated[NDArray[numpy.float64], dict(shape=(None, None), order='C', device='cpu', writable=False)]) – 4x4 pose matrix

  • rgba (tuple) – 4 value tuple of RGBA color

__module__ = 'ouster.sdk.viz'
__new__(**kwargs)
set_points(self, points: ndarray[writable=False]) None

Set the line points.

Parameters:

points (Annotated[NDArray, dict(writable=False)]) – array of floats

set_rgba(self, rgba: tuple) None

Set the color of the lines.

Parameters:

rgba (tuple) – 4 value tuple of RGBA color

set_transform(self, pose: ndarray[dtype=float64, shape=(*, *), order='C', device='cpu', writable=False]) None

Set the transform for the lines.

Parameters:

pose (Annotated[NDArray[numpy.float64], dict(shape=(None, None), order='C', device='cpu', writable=False)]) – 4x4 pose matrix

Mesh

class Mesh(self, vertices: list, face_indices: ndarray[dtype=uint32, writable=False], edge_indices: ndarray[dtype=uint32, writable=False], face_rgba: tuple, edge_rgba: tuple)

Manages the state of a single mesh.

__copy__(self) ouster.sdk.viz.Mesh
__deepcopy__(self, arg: object, /) ouster.sdk.viz.Mesh
__init__(self, vertices: list, face_indices: ndarray[dtype=uint32, writable=False], edge_indices: ndarray[dtype=uint32, writable=False], face_rgba: tuple, edge_rgba: tuple) None
__module__ = 'ouster.sdk.viz'
__new__(**kwargs)
from_simple_mesh = <nanobind.nb_func object>
set_edge_rgba(self, rgba: tuple) None

Set the edge color of the mesh.

Parameters:

rgba (tuple) – 4 value tuple of RGBA color

set_face_rgba(self, rgba: tuple) None

Set the face color of the mesh.

Parameters:

rgba (tuple) – 4 value tuple of RGBA color

set_transform(self, pose: ndarray[dtype=float64, shape=(*, *), order='C', device='cpu', writable=False]) None

Set the transform defining the mesh.

Parameters:

pose (Annotated[NDArray[numpy.float64], dict(shape=(None, None), order='C', device='cpu', writable=False)]) – 4x4 pose matrix

MouseButton

class MouseButton(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
__format__(format_spec, /)

Convert to a string according to format_spec.

__str__()

Return repr(self).

__repr__()

Return repr(self).

__new__(value)
__nb_enum__ = <capsule object NULL>
MOUSE_BUTTON_1 = 0
MOUSE_BUTTON_2 = 1
MOUSE_BUTTON_3 = 2
MOUSE_BUTTON_4 = 3
MOUSE_BUTTON_5 = 4
MOUSE_BUTTON_6 = 5
MOUSE_BUTTON_7 = 6
MOUSE_BUTTON_8 = 7
MOUSE_BUTTON_LAST = 7
MOUSE_BUTTON_LEFT = 0
MOUSE_BUTTON_RIGHT = 1
MOUSE_BUTTON_MIDDLE = 2
__module__ = 'ouster.sdk.viz'

MouseButtonEvent

class MouseButtonEvent(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
__format__(format_spec, /)

Convert to a string according to format_spec.

__str__()

Return repr(self).

__repr__()

Return repr(self).

__new__(value)
__nb_enum__ = <capsule object NULL>
MOUSE_BUTTON_RELEASED = 0
MOUSE_BUTTON_PRESSED = 1
__module__ = 'ouster.sdk.viz'

ObjectOverlay

class ObjectOverlay(self)

Manages the state of an object overlay.

__copy__(self) ouster.sdk.viz.ObjectOverlay
__deepcopy__(self, arg: object, /) ouster.sdk.viz.ObjectOverlay
__init__(self) None
__module__ = 'ouster.sdk.viz'
__new__(**kwargs)
set_cuboids(self, cuboids: collections.abc.Sequence[ouster.sdk.viz.Cuboid]) None

Set the cuboids to be displayed.

set_hshift(self, hshift: float) None

Set horizontal shift in normalized viewport screen width coordinate.

set_position(self, x_min: float, x_max: float, y_min: float, y_max: float) None

Set the display position of the overlay.

set_sensor_info(self, info: ouster.sdk.core.SensorInfo) None

Set the sensor information for projection.

set_view_matrix(self, mat: ndarray[dtype=float64, shape=(*, *), order='C', device='cpu', writable=False]) None

Set the view matrix for panorama projection.

PointViz

class PointViz(self, name: str, fix_aspect: bool = False, window_width: int = 800, window_height: int = 600, maximized: bool = False, fullscreen: bool = False, borderless: bool = False)
__annotations__ = {'camera': 'Camera', 'fps': 'float', 'notifications_enabled': 'None', 'target_display': 'TargetDisplay', 'viewport_height': 'int', 'viewport_width': 'int', 'window_height': 'int', 'window_width': 'int'}
__copy__(self) ouster.sdk.viz.PointViz
__deepcopy__(self, arg: object, /) ouster.sdk.viz.PointViz
__init__(self, name: str, fix_aspect: bool = False, window_width: int = 800, window_height: int = 600, maximized: bool = False, fullscreen: bool = False, borderless: bool = False) None
__module__ = 'ouster.sdk.viz'
__new__(**kwargs)
add(self, arg: ouster.sdk.viz.Cloud, /) None
add(self, arg: ouster.sdk.viz.Mesh, /) None
add(self, arg: ouster.sdk.viz.Cuboid, /) None
add(self, arg: ouster.sdk.viz.Label, /) None
add(self, arg: ouster.sdk.viz.Image, /) None
add(self, arg: ouster.sdk.viz.Lines, /) None
add(self, arg: ouster.sdk.viz.ObjectOverlay, /) None

Overloaded function.

  1. add(self, arg: ouster.sdk.viz.Cloud, /) -> None

    Add an object to the scene.

    Args:

    obj: A cloud, label, image or cuboid.

  2. add(self, arg: ouster.sdk.viz.Mesh, /) -> None

  3. add(self, arg: ouster.sdk.viz.Cuboid, /) -> None

  4. add(self, arg: ouster.sdk.viz.Label, /) -> None

  5. add(self, arg: ouster.sdk.viz.Image, /) -> None

  6. add(self, arg: ouster.sdk.viz.Lines, /) -> None

  7. add(self, arg: ouster.sdk.viz.ObjectOverlay, /) -> None

property camera: Camera

Get a reference to the camera controls.

cursor_visible(self, arg: bool, /) None

Toggle if the cursor is visible when over this window

property fps: float

Frames per second, updated every second in the draw() func

get_screenshot(self, width: int, height: int) numpy.ndarray[dtype=uint8, order='C']
get_screenshot(self, scale_factor: float = 1.0) numpy.ndarray[dtype=uint8, order='C']

Overloaded function.

  1. get_screenshot(self, width: int, height: int) -> numpy.ndarray[dtype=uint8, order='C']

Gets a screenshot with an explicit width and height. Returns the pixels.

  1. get_screenshot(self, scale_factor: float = 1.0) -> numpy.ndarray[dtype=uint8, order='C']

Gets a screenshot using a scale factor, which is a multiplier over the window width and height. Returns the pixels.

property notifications_enabled: None

Enable or disable notifications.

pick(self, arg0: int, arg1: int, arg2: int, arg3: int, /) None

Pick viz elements in the specified area.

pop_frame_buffer_resize_handler(self) None

Remove the last added callback for window resize events.

pop_key_handler(self) None

Remove the last added callback for handling keyboard input.

pop_mouse_button_handler(self) None

Remove the last added callback for mouse button events.

pop_mouse_pos_handler(self) None

Remove the last added callback for mouse position events.

pop_scroll_handler(self) None

Remove the last added callback for mouse scroll events.

push_frame_buffer_resize_handler(self, handler: Callable[[WindowCtx], bool]) None

Add a callback for handling window resize events.

push_key_handler(self, handler: Callable[[WindowCtx, int, int], bool]) None

Add a callback for handling keyboard input.

push_mouse_button_handler(self, handler: Callable[[WindowCtx, MouseButton, MouseButtonEvent, EventModifierKeys], bool], mode: MouseEventType = ouster.sdk.viz.MouseEventType.ANY) None

Add a callback for handling mouse button events.

push_mouse_pos_handler(self, handler: Callable[[WindowCtx, float, float], bool], mode: MouseEventType = ouster.sdk.viz.MouseEventType.ANY) None

Add a callback for handling mouse position events.

push_scroll_handler(self, handler: Callable[[WindowCtx, float, float], bool]) None

Add a callback for handling mouse scroll events.

remove(self, arg: ouster.sdk.viz.Cloud, /) bool
remove(self, arg: ouster.sdk.viz.Mesh, /) bool
remove(self, arg: ouster.sdk.viz.Cuboid, /) bool
remove(self, arg: ouster.sdk.viz.Label, /) bool
remove(self, arg: ouster.sdk.viz.Image, /) bool
remove(self, arg: ouster.sdk.viz.Lines, /) bool
remove(self, arg: ouster.sdk.viz.ObjectOverlay, /) bool

Overloaded function.

  1. remove(self, arg: ouster.sdk.viz.Cloud, /) -> bool

    Remove an object from the scene.

    Args:

    obj: A cloud, label, image or cuboid.

    Returns:

    True if the object was in the scene and was removed.

  2. remove(self, arg: ouster.sdk.viz.Mesh, /) -> bool

  3. remove(self, arg: ouster.sdk.viz.Cuboid, /) -> bool

  4. remove(self, arg: ouster.sdk.viz.Label, /) -> bool

  5. remove(self, arg: ouster.sdk.viz.Image, /) -> bool

  6. remove(self, arg: ouster.sdk.viz.Lines, /) -> bool

  7. remove(self, arg: ouster.sdk.viz.ObjectOverlay, /) -> bool

run(self) None

Run the visualizer rendering loop.

Must be called from the main thread. Will return when running(False) is called from another thread or when the visualizer window is closed.

run_once(self) None

Run one iteration of the main loop for rendering and input handling.

running(self) bool
running(self, arg: bool, /) None

Overloaded function.

  1. running(self) -> bool

Check if the rendering loop is running.

  1. running(self, arg: bool, /) -> None

Shut down the visualizer and break out of the rendering loop.

save_screenshot(self, path: str, scale_factor: float = 1.0) str
save_screenshot(self, path: str, width: int, height: int) str

Overloaded function.

  1. save_screenshot(self, path: str, scale_factor: float = 1.0) -> str

Saves a screenshot using a scale factor, which is a multiplier over the window width and height. Returns the resulting file name.

  1. save_screenshot(self, path: str, width: int, height: int) -> str

Saves a screenshot with an explicit width and height. Returns the resulting file name.

set_background_color(self, rgba: tuple) None

Set the background color of the viz.

Parameters:

rgba (tuple) – 4 value tuple of RGBA color

set_notification(self, text: str, duration: float = 2.0) None

Set a notification text to be displayed in the top-right corner of the window.

Parameters:
  • text (str) – Text to display. Empty string to clear.

  • duration (float) – Duration in seconds to display the text (default: 2.0 seconds). 0 means indefinitely.

property target_display: TargetDisplay

Get a reference to the target display.

toggle_screen_recording(self, scale_factor: float = 1.0) bool
toggle_screen_recording(self, width: int, height: int) bool

Overloaded function.

  1. toggle_screen_recording(self, scale_factor: float = 1.0) -> bool

Toggle screen recording. Returns true if started, false if stopped

  1. toggle_screen_recording(self, width: int, height: int) -> bool

Toggle screen recording with explicit width and height. Returns true if started, false if stopped.

update(self) None

Show updated data in the next rendered frame.

property viewport_height: int

Current viewport height in pixels

property viewport_width: int

Current viewport width in pixels

visible(self, arg: bool, /) None

Toggle if the PointViz window is visible

property window_height: int

Current window height in screen coordinates

property window_width: int

Current window width in screen coordinates

PointVizNotRunningError

class PointVizNotRunningError
__module__ = 'ouster.sdk.viz'
__weakref__

list of weak references to the object

TargetDisplay

class TargetDisplay

Manages the state of the camera target display.

__copy__(self) ouster.sdk.viz.TargetDisplay
__deepcopy__(self, arg: object, /) ouster.sdk.viz.TargetDisplay
__init__(*args, **kwargs)
__module__ = 'ouster.sdk.viz'
__new__(**kwargs)
enable_rings(self, state: bool) None

Enable or disable distance ring display.

get_ring_size_m(self) float

Get the distance between rings in meters.

set_ring_line_width(self, line_width: int) None

Set the line width of the rings.

set_ring_size(self, n: int) None

Set the distance between rings.

Vertex3f

class Vertex3f(self, arg0: numpy.ndarray[dtype=float32, shape=(3), order='C'], arg1: numpy.ndarray[dtype=float32, shape=(3), order='C'], /)

A vertex consisting of a position and a normal vector.

__annotations__ = {'normal': 'None', 'position': 'None'}
__copy__(self) ouster.sdk.viz.Vertex3f
__deepcopy__(self, arg: object, /) ouster.sdk.viz.Vertex3f
__init__(self, arg0: numpy.ndarray[dtype=float32, shape=(3), order='C'], arg1: numpy.ndarray[dtype=float32, shape=(3), order='C'], /) None
__module__ = 'ouster.sdk.viz'
__new__(**kwargs)
property normal: None

vertex normal

property position: None

vertex position

WindowCtx

class WindowCtx(self)

Context for input callbacks.

__annotations__ = {'lbutton_down': 'bool', 'mbutton_down': 'bool', 'mouse_x': 'float', 'mouse_y': 'float', 'rbutton_down': 'bool', 'viewport_height': 'int', 'viewport_width': 'int', 'window_height': 'int', 'window_width': 'int'}
__copy__(self) ouster.sdk.viz.WindowCtx
__deepcopy__(self, arg: object, /) ouster.sdk.viz.WindowCtx
__init__(self) None
__module__ = 'ouster.sdk.viz'
__new__(**kwargs)
aspect_ratio(self) float

Return the aspect ratio of the viewport.

property lbutton_down: bool

True if the left mouse button is held

property mbutton_down: bool

True if the middle mouse button is held

property mouse_x: float

Current mouse x position

property mouse_y: float

Current mouse y position

normalized_coordinates(self, arg0: float, arg1: float, /) tuple[float, float]

Return 2d normalized viewport coordinates given window coordinates.

property rbutton_down: bool

True if the right mouse button is held

property viewport_height: int

Current viewport height in pixels

property viewport_width: int

Current viewport width in pixels

property window_height: int

Current window height in screen coordinates

property window_width: int

Current window width in screen coordinates

add_default_controls

add_default_controls(arg: ouster.sdk.viz.PointViz, /) None

Add default keyboard and mouse bindings to a visualizer instance.

Submodules

ouster.sdk.viz.accum_base

class AccumulatorBase(model, point_viz, track)[source]

Bases: object

The base of any class used in LidarFrameVizAccumulators that displays data accumulated from frames.

Parameters:
property active_cloud_mode: str

Name of current color mode of point ACCUM/MAP point clouds

cycle_cloud_mode(*, direction=1)[source]

Change the coloring mode of the point cloud for MAP/ACCUM clouds

Parameters:

direction (int)

cycle_cloud_palette(*, direction=1)[source]

Change the color palette of the point cloud for MAP/ACCUM clouds

Parameters:

direction (int)

get_palette(cloud_mode)[source]
Return type:

CloudPaletteItem

Parameters:

cloud_mode (CloudMode)

property metadata: List[SensorInfo]

Metadatas for the displayed sensors.

toggle_visibility(state=None)[source]
Parameters:

state (bool | None)

update(frame, frame_num=None)[source]

Register the new frame and update the states of TRACK, ACCUM and MAP :rtype: None

Parameters:
  • frame (FrameSet)

  • frame_num (int | None)

Return type:

None

ouster.sdk.viz.accumulators_config

Copyright (c) 2023, Ouster, Inc. All rights reserved.

Ouster frame accumulation for LidarFrameViz

class LidarFrameVizAccumulatorsConfig(accum_max_num=0, accum_min_dist_meters=0, accum_min_dist_num=0, map_enabled=False, map_select_ratio=0.001, map_max_points=1500000, map_overflow_from_start=False)[source]

Bases: object

Represents configuration for AccumulatorBase implementations used within LidarFrameVizAccumulators.

Parameters:
  • accum_max_num (int)

  • accum_min_dist_meters (float)

  • accum_min_dist_num (int)

  • map_enabled (bool)

  • map_select_ratio (float)

  • map_max_points (int)

  • map_overflow_from_start (bool)

ouster.sdk.viz.frames_accumulator

Copyright (c) 2023, Ouster, Inc. All rights reserved.

class FramesAccumulator(model, point_viz, track)[source]

Bases: AccumulatorBase

Used by LidarFrameVizAccumulators to display every Nth frame or a frame at every K meters.

Parameters:
property accum_visible: bool

Whether accumulated key frames (ACCUM) is visible

toggle_sensor(sensor_idx, state)[source]
Parameters:
  • sensor_idx (int)

  • state (bool)

toggle_visibility(state=None)[source]

Toggle or set the visibility of the accumulated frames.

Parameters:

state (bool | None)

update(frame, frame_num=None, force_update=False)[source]

Register the new frame and update the states of TRACK, ACCUM and MAP :rtype: None

Parameters:
  • frame (FrameSet)

  • frame_num (int | None)

  • force_update (bool)

Return type:

None

update_point_size(point_size)[source]
Parameters:

point_size (float)

class SensorClouds(viz, sensor, track)[source]

Bases: object

Encapsulates the render state for a single sensor in FramesAccumulator.

Parameters:
add_cloud(i, accum_visible, active_cloud_palette, sr)[source]
Return type:

bool

Parameters:
hide_clouds()[source]
remove_cloud(i)[source]
Return type:

None

set_palette(active_cloud_palette)[source]
Parameters:

active_cloud_palette (CloudPaletteItem)

show_clouds()[source]
update(accum_visible, active_cloud_mode_name, active_cloud_palette, force_update=False)[source]
Parameters:
  • accum_visible (bool)

  • active_cloud_mode_name (str)

  • active_cloud_palette (CloudPaletteItem)

  • force_update (bool)

update_cloud(i, active_cloud_mode_name, sr)[source]
Parameters:
update_point_size(point_size)[source]
Parameters:

point_size (float)

ouster.sdk.viz.map_accumulator

class MapAccumulator(model, point_viz, track, config)[source]

Bases: AccumulatorBase

Used by LidarFrameVizAccumulators to display a point cloud that is produced by all frames in the source data.

Parameters:
property map_visible: bool

Whether overall map (MAP) is visible

toggle_visibility(state=None)[source]
Parameters:

state (bool | None)

update(frame, frame_num=None)[source]

Register the new frame and update the states of TRACK, ACCUM and MAP :rtype: None

Parameters:
  • frame (FrameSet)

  • frame_num (int | None)

Return type:

None

update_point_size(point_size)[source]
Parameters:

point_size (float)

ouster.sdk.viz.mesh

clouds_from_zrb(viz, zrb, xyzlut)[source]
Parameters:

zrb (Zrb)

load_sensor_info(file_path)[source]
Parameters:

file_path (str)

mesh_from_stl(simple_mesh, sensor_info, add_faces=True, add_edges=True)[source]
Parameters:

sensor_info (SensorInfo)

voxel_style_mesh_from_zrb(zrb, metadata, voxel_vertices, add_faces=True, add_edges=True)[source]
Parameters:

ouster.sdk.viz.model

Copyright (c) 2021, Ouster, Inc. All rights reserved.

Types for managing visualization state.

class ImgModeItem(mode, name, return_num=0)[source]

Bases: object

Image mode for specific return with explicit name.

Parameters:
  • mode (ImageMode)

  • name (str)

  • return_num (int)

mode: ImageMode
name: str
return_num: int = 0
class LidarFrameVizModel(viz, metas, *, _img_aspect_ratio)[source]

Bases: object

Parameters:
clear_aoi()[source]
clear_masks()[source]
clear_object_selection()[source]
cycle_cloud_mode(direction)[source]

Updates the currently selected cloud mode from the list of all available cloud modes.

Parameters:

direction (int)

cycle_image_mode(i, direction)[source]

Updates the currently selected image mode from the list of all available cloud modes.

Parameters:
  • i (int)

  • direction (int)

finish()[source]

Stop any background processing

flip_images(flip)[source]
Return type:

None

Parameters:

flip (bool)

image_and_pixel_for_viewport_coordinate(ctx, x, y)[source]
property metadata: List[SensorInfo]

Metadatas for the displayed sensors.

mouse_button_handler(ctx, button, event, mods)[source]
Return type:

bool

Parameters:
mouse_pos_handler(ctx, x, y)[source]
Return type:

bool

Parameters:
select_cloud_mode(name)[source]

Updates the currently selected cloud mode from the list of all available cloud modes. Returns false if the requested mode is not available. :rtype: bool

Parameters:

name (str)

Return type:

bool

select_image_mode(i, name)[source]

Updates the currently selected image mode from the list of all available cloud modes. Returns false if the requested mode is not available. :rtype: bool

Parameters:
  • i (int)

  • name (str)

Return type:

bool

set_class_maps(class_maps)[source]

Set the class maps for the visualizer. :rtype: None

Parameters:

class_maps (ClassMapSet)

Return type:

None

show_one_image(do)[source]
Return type:

None

Parameters:

do (bool)

sorted_cloud_mode_names()[source]

Returns all the cloud mode names.

sorted_image_mode_names()[source]

Returns the image mode names, limited to those for fields we’ve seen in at least one LidarFrame.

toggle_flip_images()[source]
Return type:

None

update(frames, new_frames=True)[source]

Update the LidarFrameViz state with the provided frames. :rtype: None

Parameters:
Return type:

None

update_3d_aoi(force_origin=False)[source]
update_aoi(ctx=None)[source]
Parameters:

ctx (WindowCtx | None)

update_aoi_label(frames)[source]
Parameters:

frames (FrameSet)

update_cloud_palette_name()[source]

Gets the name of the palette used for the point clouds.

update_cloud_palettes()[source]

Updates the point clouds to use the currently-selected palette.

update_image_size(amount)[source]

Change the size of the 2D image and position image labels. :rtype: None

Parameters:

amount (int)

Return type:

None

update_object_cuboids()[source]

Add or remove cuboids from the viz based on the current object view mode. :rtype: None

Return type:

None

update_objects(frames)[source]

Update the objects in the viz from the given FrameSet. :rtype: None

Parameters:

frames (FrameSet)

Return type:

None

update_objects_for_list(key, object_list)[source]
Parameters:

key (str)

update_overlay_colors(palette)[source]
class ObjectColorMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

OBJECT_CLASS = 1
OBJECT_ID = 0
class ObjectViewMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

MAIN_VIEW_ONLY = 2
NONE = 3
OVERLAY_AND_MAIN_VIEW = 0
OVERLAY_ONLY = 1
class Palettes(_ext_palettes)[source]

Bases: object

Represents the color palettes used within an instance of LidarFrameViz. Also keeps track of the palette currently in use.

Initialize a Palettes object, which populates two lists of palettes - one for normal view modes and one for ReflMode.

Parameters:

_ext_palettes (List[CloudPaletteItem])

cycle_cloud_palette(direction)[source]

Updates the current palette to use. :rtype: None

Parameters:

direction (int)

Return type:

None

get_current_palette()[source]

Gets the name of the current palette. :rtype: CloudPaletteItem

Return type:

CloudPaletteItem

get_palette(cloud_mode)[source]

Gets the current color palette depending on the view mode. :rtype: CloudPaletteItem

Parameters:

cloud_mode (CloudMode)

Return type:

CloudPaletteItem

get_palette_by_name(name)[source]
Return type:

CloudPaletteItem

Parameters:

name (str)

set_palette(index)[source]

Set the current palette index. :rtype: None

Parameters:

index (int)

Return type:

None

class Selection2d(p1, p2, sensor_index, sensor, image_index, image)[source]

Bases: object

Parameters:
  • p1 (Tuple[int, int])

  • p2 (Tuple[int, int])

  • sensor_index (int)

  • sensor (SensorModel)

  • image_index (int)

  • image (Image)

property area: int

Calculates and returns the area of the rectangular selection.

The area is calculated as the absolute difference between the x and y coordinates, ensuring a positive result regardless of the points’ order.

finalize()[source]
property finalized
property p1
property p2
property sensor
class SensorModel(viz, meta, *, _img_aspect_ratio=0, palettes=<ouster.sdk.viz.model.Palettes object>, index=None)[source]

Bases: object

A model object representing viz state for a single sensor.

Parameters:
  • viz (PointViz)

  • _img_aspect_ratio (float)

  • palettes (Palettes)

  • index (int | None)

hide_all_zone_geometry()[source]
set_zone_selection_and_render_mode(selection_mode, render_mode)[source]
Parameters:
update_cloud(cloud, cloud_mode, range_field, return_num, frame)[source]

Updates the given Cloud with the given CloudMode. :rtype: None

Parameters:
  • range_field (str)

  • return_num (int)

  • frame (LidarFrame | None)

Return type:

None

update_cloud_palettes(cloud_mode_name)[source]

Sets each cloud palette given the cloud mode name. Has no effect if the cloud mode is not available for this sensor. :rtype: None

Return type:

None

update_clouds(cloud_mode_name, frame)[source]

Update range and mode for each cloud given a mode name and a frame. :rtype: None

Parameters:
Return type:

None

update_image(image, image_mode_item, frame)[source]

Update the view mode of the given image. :rtype: None

Parameters:
Return type:

None

update_images(image_mode_names, frame)[source]

Update image values and mode given mode names and a frame. :rtype: None

Parameters:
  • image_mode_names (List[str])

  • frame (LidarFrame | None)

Return type:

None

update_object_id_cloud_and_image_masks(frame, mask_palette)[source]
Parameters:

frame (LidarFrame | None)

update_zone_occupancy_cloud_and_image_masks(frame, palettes)[source]
Parameters:
update_zones(frame=None)[source]
Return type:

None

Parameters:

frame (LidarFrame | None)

class VizExtraMode(func)[source]

Bases: object

Image/Cloud mode factory func

Used to embed viz modes from external plugins.

Parameters:

func (Callable[[], ImageCloudMode | ImageMode | CloudMode])

create(info=None)[source]
Return type:

Union[ImageCloudMode, ImageMode, CloudMode]

Parameters:

info (SensorInfo | None)

func: Callable[[], Union[ImageCloudMode, ImageMode, CloudMode]]
class ZoneRenderMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

CLOUDS = 1
STL = 0
STL_AND_CLOUDS = 2
VOXEL_MESH = 3
class ZoneSelectionMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

ALL = 2
LIVE = 1
NONE = 0
triggered_live_zone_color(palette, zone_id)[source]

ouster.sdk.viz.scans_accumulator

Copyright (c) 2024, Ouster, Inc. All rights reserved.

Deprecated module. Use ouster.sdk.viz.frames_accumulator instead.

ouster.sdk.viz.track

Copyright (c) 2023, Ouster, Inc. All rights reserved.

class FrameRecord(pose, frame, cloud_mode_keys=<factory>)[source]

Bases: object

Represents a frame, its pose, and its color (aka keys) for each available cloud mode.

Parameters:
  • pose (ndarray)

  • frame (LidarFrame)

  • cloud_mode_keys (Dict[str, ndarray | None])

cloud_mode_keys: Dict[str, Optional[ndarray]]
frame: LidarFrame
pose: ndarray
property position
class MultiTrack(model, config)[source]

Bases: object

Represents frame positions and key frames for multiple sensors.

Parameters:
clear()[source]
Return type:

None

update(frames, frame_num=None)[source]

Update the Track for each sensor. :rtype: None

Parameters:
  • frames (FrameSet)

  • frame_num (int | None)

Return type:

None

class Track(config, extrinsics=array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]))[source]

Bases: object

Represents a sequence of frames with their poses and “key frames”, which are frames representing every Nth frame or every few meters.

Parameters:
clear()[source]
Return type:

None

property key_frames_num: int

Current number of key frames

update(frame, frame_num)[source]

Register the new frame and update the track and key frames :rtype: None

Parameters:
Return type:

None

ouster.sdk.viz.tracks_accumulator

Copyright (c) 2023, Ouster, Inc. All rights reserved.

class TracksAccumulator(model, point_viz, track)[source]

Bases: AccumulatorBase

Encapsulates render state for tracks (frame positions) and key frames (which are “interesting” frame positions according to the LidarFrameVizAccumulatorsConfig.) Cloud objects (from the ouster_viz library) are used to render the tracks.

Parameters:
DEFAULT_KF_PT_SIZE = 10
DEFAULT_PT_SIZE = 5
toggle_visibility(state=None)[source]

Toggle track visibility by adding or removing the Clouds used to render it to / from the viz.

Parameters:

state (bool | None)

property track_visible: bool

Returns true if the track is visible.

ouster.sdk.viz.widgets

class Toggle(viz, item, initially_visible=False)[source]

Bases: object

Parameters:
  • viz (PointViz)

  • item (Any)

  • initially_visible (bool)

hide()[source]
show()[source]
toggle()[source]
property visible: bool
class ToggleCloud(viz, cloud, initially_visible=False)[source]

Bases: Toggle

Parameters:
class ToggleImage(viz, initially_visible=False)[source]

Bases: Toggle

This class encapsulates properties of an image, such as whether it is visible in the supplied PointViz instance. This makes up for a deficiency in PointViz which requires that API users remember whether a widget has been added or not.

Parameters:
  • viz (PointViz)

  • initially_visible (bool)

property hshift
property position
set_image(image)[source]
Parameters:

image (ndarray)

class ToggleLabel(viz, initial_text, initial_position, initially_visible=False, align_right=False, align_top=False)[source]

Bases: Toggle

This class encapsulates properties of a label, such as whether it is visible in the supplied PointViz instance. This makes up for a deficiency in PointViz which requires that API users remember whether a widget has been added or not.

Parameters:
  • viz (PointViz)

  • initial_text (str)

  • initial_position (Tuple[float, float] | Tuple[float, float, float])

  • initially_visible (bool)

  • align_right (bool)

  • align_top (bool)

property position
property rgba
property scale
property text
property text_height
class ToggleMesh(viz, mesh, initially_visible=False)[source]

Bases: Toggle

Parameters: