Module ouster.sdk.viz

ouster.sdk.viz.accum_base

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

Bases: object

The base of any class used in LidarScanVizAccumulators that displays data accumulated from scans.

property metadata: List[SensorInfo]

Metadatas for the displayed sensors.

get_palette(cloud_mode)[source]
Return type:

CloudPaletteItem

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

cycle_cloud_palette(*, direction=1)[source]

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

update(scan, scan_num=None)[source]

Register the new scan and update the states of TRACK, ACCUM and MAP

Return type:

None

toggle_visibility(state=None)[source]

ouster.sdk.viz.accumulators

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

Ouster scan accumulation for LidarScanViz

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

Bases: object

Accumulate scans, track poses and overall map view Every new scan (LidarScan or List[Optional[LidarScan]]) is passed through update(scan, num).

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

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

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

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

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

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

  • config (LidarScanVizAccumulatorsConfig) –

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

    (ACCUM) scans 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

    scans between accumulated (ACCUM) key frames

    map_enabled: enable overall map accumulation (MAP) (--map) map_select_ratio: percent of points to select from the scans 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

cycle_cloud_mode(direction)[source]
Return type:

bool

cycle_cloud_palette(direction)[source]
Return type:

bool

update_point_size(amount)[source]

Change the point size of the MAP/ACCUM point cloud.

Return type:

bool

toggle_sensor(sensor_idx, state)[source]
toggle_mode_accum(state=None)[source]

Toggle ACCUM view

Return type:

bool

toggle_mode_map(state=None)[source]

Toggle MAP view

Return type:

bool

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

bool

toggle_osd(state=None)[source]

Show or hide the on-screen display.

Return type:

bool

osd_text()[source]

Prepare OSD text for use in draw_osd or elsewhere.

Return type:

str

update(scans, scan_num=None)[source]

Updates the accumulation state from the current scan. 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().

Return type:

None

draw(update=True)[source]

Process and draw the latest state to the screen.

Return type:

None

ouster.sdk.viz.accumulators_config

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

Ouster scan accumulation for LidarScanViz

class LidarScanVizAccumulatorsConfig(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 LidarScanVizAccumulators.

ouster.sdk.viz.core

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

Sensor data visualization tools.

Visualize lidar data using OpenGL.

class PointViz

Bases: pybind11_object

add()

Add an object to the scene.

Parameters:

obj – A cloud, label, image or cuboid.

property camera

Get a reference to the camera controls.

property fps

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

get_screenshot()

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

pop_frame_buffer_handler()

Remove the last added callback for handling frame buffers data.

pop_key_handler()

Remove the last added callback for handling keyboard input.

pop_mouse_button_handler()

Remove the last added callback for mouse button events.

pop_mouse_pos_handler()

Remove the last added callback for mouse position events. Remove the last added callback for window resize events.

pop_scroll_handler()

Remove the last added callback for mouse scroll events.

push_frame_buffer_handler()

Add a callback for handling every frame buffer draw (super expensive).

push_frame_buffer_resize_handler()

Add a callback for handling window resize events.

push_key_handler()

Add a callback for handling keyboard input.

push_mouse_button_handler()

Add a callback for handling mouse button events.

push_mouse_pos_handler()

Add a callback for handling mouse position events.

push_scroll_handler()

Add a callback for handling mouse scroll events.

remove()

Remove an object from the scene.

Parameters:

obj – A cloud, label, image or cuboid.

Returns:

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

run()

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()

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

running()

Check if the rendering loop is running. Shut down the visualizer and break out of the rendering loop.

save_screenshot()

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

property target_display

Get a reference to the target display.

toggle_screen_recording()

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

update()

Show updated data in the next rendered frame.

property viewport_height

Current viewport height in pixels

property viewport_width

Current viewport width in pixels

visible()

Toggle if the PointViz window is visible

property window_height

Current window height in screen coordinates

property window_width

Current window width in screen coordinates

class Cloud

Bases: pybind11_object

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.

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

Unstructured point cloud for visualization.

Call set_xyz() to update

Parameters:
  • n – number of points

  • extrinsics – sensor extrinsic calibration. 4x4 column-major homogeneous transformation matrix.

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

Structured point cloud for visualization.

Call set_range() to update

Parameters:

info – sensor metadata

property cols

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

set_column_poses()

Set scan poses (per every column).

Parameters:

column_poses – array of poses (Wx4x4) per every column.

set_key()

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 – array of at least as many elements as there are points, preferably normalized between 0 and 1

set_key_rgb()

Set the key to RGB values, used for colouring.

Size must be: - 2 dimensions with last dimension 3 for unordered pointclouds - 3 dimensions with last dimension 3 for ordered pointclouds

Parameters:

key – array of RGB colors as many elements as there are points

set_key_rgba()

Set the key to RGBA values, used for colouring.

Size must be: - 2 dimensions with last dimension 4 for unordered pointclouds - 3 dimensions with last dimension 4 for ordered pointclouds

Parameters:

key – array of RGBA colors as many elements as there are points

set_mask()

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

Parameters:

mask – array of at least 4x as many elements as there are points, preferably normalized between 0 and 1

set_palette()

Set the point cloud color palette.

Parameters:

palette – the new palette to use, must have size 3*palette_size

set_point_size()

Set point size.

Parameters:

size – point size

set_pose()

Set the ith point cloud pose.

Parameters:

pose – 4x4 column-major homogeneous transformation matrix

set_range()

Set the range values.

Parameters:

range – array of at least as many elements as there are points, representing the range of the points

set_xyz()

Set the XYZ values.

Parameters:

xyz (array of np.float32. Pybind should also cast other numpy types (but we haven't tested thoroughly)) –

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

Number of points in a cloud

class Image

Bases: pybind11_object

Manages the state of an image.

clear_palette()

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

image_pixel_to_viewport_coordinates()

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

pixel_size()

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

set_hshift()

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()

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 – 2D array of floats for a monochrome image or 3D array with RGB or RGBA components for color image.

set_mask()

Set the RGBA mask.

Parameters:

mask – M x N x 4 array with RGBA mask

set_palette()

Set the image color palette.

Parameters:

palette – the new palette to use, must have size 3*palette_size

set_position()

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 – min x

  • x_max – max x

  • y_min – min y

  • y_max – max y

viewport_coordinates_to_image_pixel()

Returns the image pixel as a (row, col) tuple given window coordinates, or None if the given window coordinate is not within the image.

class Cuboid

Bases: pybind11_object

Manages the state of a single cuboid.

Creates cuboid.

Parameters:
  • pose – 4x4 pose matrix

  • rgba – 4 value tuple of RGBA color

set_rgba()

Set the color of the cuboid.

Parameters:

rgba – 4 value tuple of RGBA color

set_transform()

Set the transform defining the cuboid.

Applied to a unit cube centered at the origin.

Parameters:

pose – 4x4 pose matrix

class Label

Bases: pybind11_object

Manages the state of a text label.

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

Creates 3D Label.

Parameters:
  • text – label text

  • x – label location

  • y – label location

  • z – label location

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

Creates 2D Label.

Parameters:
  • text – label text

  • x – label 2D location in screen coords [0..1], corresponding to top left corner of label

  • 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

set_position()

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

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: if True - anchor point of the label is the right side align_top: if True - anchor point of the label is the top side

set_rgba()

Set the color of the label.

Parameters:

rgba – 4 value tuple of RGBA color

set_scale()

Set scaling factor of the label.

Parameters:

scale – text scale factor

set_text()

Update label text.

Parameters:

text – new text to display

class WindowCtx

Bases: pybind11_object

Context for input callbacks.

aspect_ratio()

Return the aspect ratio of the viewport.

property lbutton_down

True if the left mouse button is held

property mbutton_down

True if the middle mouse button is held

property mouse_x

Current mouse x position

property mouse_y

Current mouse y position

normalized_coordinates()

Return 2d normalized viewport coordinates given window coordinates.

property viewport_height

Current viewport height in pixels

property viewport_width

Current viewport width in pixels

property window_height

Current window height in screen coordinates

property window_width

Current window width in screen coordinates

class Camera

Bases: pybind11_object

Controls the camera view and projection.

dolly()

Move the camera towards or away from the target.

dolly_xy()

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

Parameters:
  • x – horizontal offset

  • y – vertical offset

get_dolly()

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

get_fov()

Get the diagonal field of view in degrees.

get_pitch()

Get pitch in degrees.

get_proj_offset()

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

get_target()

Get a pose of the camera target.

get_view_offset()

Get view offset of a camera

get_yaw()

Get yaw in degrees.

is_orthographic()

Get the orthographic state.

pitch()

Pitch the camera up or down.

reset()

Reset the camera view and fov.

set_dolly()

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

set_fov()

Set the diagonal field of view.

set_orthographic()

Use an orthographic or perspective projection.

set_pitch()

Set pitch in degrees.

set_proj_offset()

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

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

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

set_target()

Set the camera target pose (inverted pose).

Parameters:

pose – 4x4 column-major homogeneous transformation matrix

set_view_offset()

Set view offset of a camera

set_yaw()

Set yaw in degrees.

yaw()

Orbit the camera left or right about the camera target.

class TargetDisplay

Bases: pybind11_object

Manages the state of the camera target display.

enable_rings()

Enable or disable distance ring display.

set_ring_line_width()

Set the line width of the rings.

set_ring_size()

Set the distance between rings.

add_default_controls()

Add default keyboard and mouse bindings to a visualizer instance.

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.

Return type:

None

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.

Return type:

None

class CloudPaletteItem(name, palette)[source]

Bases: object

Palette with a name

name: str
palette: ndarray
class VizExtraMode(func)[source]

Bases: object

Image/Cloud mode factory func

Used to embed viz modes from external plugins.

func: Callable[[], Union[ImageCloudMode, ImageMode, CloudMode]]
create(info=None)[source]
Return type:

Union[ImageCloudMode, ImageMode, CloudMode]

class LidarScanViz(metas, point_viz=None, accumulators_config=None, *, _img_aspect_ratio=0, _ext_modes=None, _ext_palettes=None)[source]

Bases: object

Multi LidarScan clouds visualizer

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

Parameters:
  • metas (List[SensorInfo]) – sensor metadata used to interpret scans

  • viz – use an existing PointViz instance instead of creating one

class OsdState(value)[source]

Bases: Enum

An enumeration.

NONE = (<enum.auto object>,)
DEFAULT = (<enum.auto object>,)
HELP = 1
class FlagsMode(value)[source]

Bases: Enum

An enumeration.

NONE = 0
HIGHLIGHT_SECOND = 1
HIGHLIGHT_BLOOM = 2
HIDE_BLOOM = 3
class ImagesLayout(value)[source]

Bases: Enum

An enumeration.

HORIZONTAL = 0
VERTICAL = 1
class CameraMode(value)[source]

Bases: Enum

An enumeration.

FOLLOW = 0
FOLLOW_ROTATION_LOCKED = 1
FIXED = 2
mouse_button_handler(ctx, button, event, mods)[source]
Return type:

bool

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

bool

frame_buffer_resize_handler(ctx)[source]
property metadata: List[SensorInfo]

Metadatas for the displayed sensors.

property osd_state: OsdState

Returns the state of the on screen display.

MAX_SENSOR_TOGGLE_KEYS = 9
select_img_mode(i, mode)[source]

Change the displayed field of the i’th image.

Return type:

bool

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

Change the displayed field of the i’th image.

Return type:

None

select_cloud_mode(mode)[source]

Change the coloring mode of the 3D point cloud.

Return type:

bool

cycle_cloud_mode(direction=1)[source]

Change the coloring mode of the 3D point cloud.

Return type:

None

cycle_cloud_palette(*, direction=1)[source]

Change the color palette of the 3D point cloud.

Return type:

None

toggle_cloud(i)[source]

Toggle whether the i’th return is displayed.

Return type:

None

toggle_sensor(sensor_index)[source]

Toggle whether the i’th sensor data is displayed.

Return type:

None

update_point_size(amount)[source]

Change the point size of the 3D cloud.

Return type:

None

update_image_size(amount)[source]

Change the size of the 2D image and position image labels.

Return type:

None

toggle_flip_images()[source]

Toggle if 2D images should be flipped or not.

Return type:

None

update_ring_size(amount)[source]

Change distance ring size.

Return type:

None

cicle_ring_line_width()[source]

Change rings line width.

Return type:

None

toggle_osd(state=None)[source]

Show or hide the on-screen display.

Return type:

None

cycle_camera_mode(direction=1)[source]

Toggle the camera follow mode.

Return type:

None

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

None

toggle_axis_markers()[source]

Toggle the helper axis of a scan ON/OFF

Return type:

None

property scan: List[LidarScan | None]

The currently displayed scan.

property scan_num: int

The currently displayed scan number

update(scans, scan_num=None)[source]

Update the LidarScanViz state with the provided scans.

Return type:

None

draw(update=True)[source]

Process and draw the latest state to the screen.

Return type:

None

run()[source]

Run the rendering loop of the visualizer.

See PointViz.run()

Return type:

None

print_key_bindings()[source]
Return type:

None

toggle_help()[source]
Return type:

None

push_point_viz_handler(viz, arg, handler)[source]

Add a key handler with extra context without keeping it alive.

It’s often useful to add a key callback that calls a method of an object that wraps a PointViz instance. In this case it’s necessary to take some extra care to avoid a reference cycle; holding onto self in the callback passed to native code would cause a memory leak.

Parameters:
  • viz (PointViz) – The PointViz instance.

  • arg (TypeVar(T)) – The extra context to pass to handler; often self.

  • handler (Callable[[TypeVar(T), WindowCtx, int, int], bool]) – Key handler callback taking an extra argument

Return type:

None

ls_show(scans, *, title=None)[source]

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

Parameters:

scans (Union[Slicer, LidarScan, List[LidarScan], List[List[LidarScan]]]) – A set of LidarScans to visualize.

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.

ouster.sdk.viz.map_accumulator

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

Bases: AccumulatorBase

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

toggle_visibility(state=None)[source]
property map_visible: bool

Whether overall map (MAP) is visible

update(scan, scan_num=None)[source]

Register the new scan and update the states of TRACK, ACCUM and MAP

Return type:

None

update_point_size(point_size)[source]

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.

mode: ImageMode
name: str
return_num: int = 0
class VizExtraMode(func)[source]

Bases: object

Image/Cloud mode factory func

Used to embed viz modes from external plugins.

func: Callable[[], Union[ImageCloudMode, ImageMode, CloudMode]]
create(info=None)[source]
Return type:

Union[ImageCloudMode, ImageMode, CloudMode]

class Palettes(_ext_palettes)[source]

Bases: object

Represents the color palettes used within an instance of LidarScanViz. 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.

set_palette(index)[source]

Set the current palette index.

Return type:

None

cycle_cloud_palette(direction)[source]

Updates the current palette to use.

Return type:

None

get_palette(cloud_mode)[source]

Gets the current color palette depending on the view mode.

Return type:

CloudPaletteItem

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

Bases: object

property sensor
property finalized
finalize()[source]
property p1
property p2
class SensorModel(meta, *, _img_aspect_ratio=0)[source]

Bases: object

A model object representing viz state for a single sensor.

update_cloud_palettes(cloud_mode_name, palettes)[source]

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

Return type:

None

update_cloud(cloud, cloud_mode, range_field, return_num, scan)[source]

Updates the given Cloud with the given CloudMode.

Return type:

None

update_clouds(cloud_mode_name, scan)[source]

Update range and mode for each cloud given a mode name and a scan.

Return type:

None

update_image(image, image_mode_item, scan)[source]

Update the view mode of the given image.

Return type:

None

update_images(image_mode_names, scan)[source]

Update image values and mode given mode names and a scan.

Return type:

None

class LidarScanVizModel(metas, *, _img_aspect_ratio)[source]

Bases: object

property metadata: List[SensorInfo]

Metadatas for the displayed sensors.

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.

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 LidarScan.

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.

Return type:

bool

cycle_cloud_mode(direction)[source]

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

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.

Return type:

bool

cycle_image_mode(i, direction)[source]

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

update(scans)[source]

Update the LidarScanViz state with the provided scans.

Return type:

None

clear_masks()[source]
clear_aoi()[source]
image_and_pixel_for_viewport_coordinate(ctx, x, y)[source]
mouse_button_handler(ctx, button, event, mods)[source]
Return type:

bool

update_aoi(ctx=None)[source]
mouse_pos_handler(ctx, x, y)[source]
Return type:

bool

update_aoi_label(scans)[source]
flip_images(flip)[source]
Return type:

None

toggle_flip_images()[source]
Return type:

None

update_image_size(amount)[source]

Change the size of the 2D image and position image labels.

Return type:

None

ouster.sdk.viz.scans_accumulator

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

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

Bases: object

Encapsulates the render state for a single sensor in ScansAccumulator.

remove_cloud(i)[source]
Return type:

None

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

bool

update_cloud(i, active_cloud_mode_name, sr)[source]
show_clouds()[source]
hide_clouds()[source]
update(accum_visible, active_cloud_mode_name, active_cloud_palette, force_update=False)[source]
set_palette(active_cloud_palette)[source]
update_point_size(point_size)[source]
class ScansAccumulator(model, point_viz, track)[source]

Bases: AccumulatorBase

Used by LidarScanVizAccumulators to display every Nth scan or a scan at every K meters.

update_point_size(point_size)[source]
update(scan, scan_num=None, force_update=False)[source]

Register the new scan and update the states of TRACK, ACCUM and MAP

Return type:

None

property accum_visible: bool

Whether accumulated key frames (ACCUM) is visible

toggle_sensor(sensor_idx, state)[source]
toggle_visibility(state=None)[source]

Toggle or set the visibility of the accumulated scans.

ouster.sdk.viz.track

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

class ScanRecord(pose, scan, cloud_mode_keys=<factory>)[source]

Bases: object

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

pose: ndarray
scan: LidarScan
cloud_mode_keys: Dict[str, Optional[ndarray]]
property position
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 scans with their poses and “key frames”, which are scans representing every Nth scan or every few meters.

property key_frames_num: int

Current number of key frames

update(scan, scan_num)[source]

Register the new scan and update the track and key frames

Return type:

None

class MultiTrack(model, config)[source]

Bases: object

Represents scan positions and key frames for multiple sensors.

update(scans, scan_num=None)[source]

Update the Track for each sensor.

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 (scan positions) and key frames (which are “interesting” scan positions according to the LidarScanVizAccumulatorsConfig.) Cloud objects (from the ouster_viz library) are used to render the tracks.

DEFAULT_PT_SIZE = 5
DEFAULT_KF_PT_SIZE = 10
property track_visible: bool

Returns true if the track is visible.

toggle_visibility(state=None)[source]

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

ouster.sdk.viz.util

class BoundMethod(method)[source]

Bases: object

Used to wrap a bound method’s instance with a weak ref, which is necessary to use the method as a PointViz event callback while allowing the bound method’s instance to be deleted.

push_point_viz_handler(viz, arg, handler)[source]

Add a key handler with extra context without keeping it alive.

It’s often useful to add a key callback that calls a method of an object that wraps a PointViz instance. In this case it’s necessary to take some extra care to avoid a reference cycle; holding onto self in the callback passed to native code would cause a memory leak.

Parameters:
  • viz (PointViz) – The PointViz instance.

  • arg (TypeVar(T)) – The extra context to pass to handler; often self.

  • handler (Callable[[TypeVar(T), WindowCtx, int, int], bool]) – Key handler callback taking an extra argument

Return type:

None

push_point_viz_fb_handler(viz, arg, handler)[source]

Add a frame buffer handler with extra context without keeping it alive.

See docs for push_point_viz_handler() method above for details.

Parameters:
  • viz (PointViz) – The PointViz instance.

  • arg (TypeVar(T)) – The extra context to pass to handler; often self.

  • handler (Callable[[TypeVar(T), List, int, int], bool]) – Frame buffer handler callback taking an extra argument

Return type:

None

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=None, enabled=True)[source]

Bases: object

Coordinate axis with a text label.

property enabled: bool

True if label is added to the viz

enable()[source]

Enable the label and make it added to the viz

Return type:

None

disable()[source]

Disable the label and remove it from the viz

Return type:

None

toggle()[source]

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

Return type:

bool

property pose: ndarray

Label pose, 4x4 matrix

property label: str

Label text, 4x4 matrix

update()[source]

Update label component viz states.

Return type:

None

ouster.sdk.viz.view_mode

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

Bases: Protocol

LidarScan field processor

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

property name: str

Name of the view mode

property names: List[str]

Name of the view mode per return number

enabled(ls, return_num=0)[source]

Checks the view mode availability for a scan and return number

Return type:

bool

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.

Return type:

None

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.

Return type:

None

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

Bases: ImageMode, CloudMode, Protocol

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

class RingMode(info)[source]

Bases: CloudMode

View mode to show laser ring.

Parameters:

info (SensorInfo) – sensor metadata

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.

Return type:

None

enabled(ls, return_num=0)[source]

Checks the view mode availability for a scan and return number

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

Bases: ImageCloudMode

Basic view mode with AutoExposure and BeamUniformityCorrector

Handles single and dual returns scans.

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

property name: str

Name of the view mode

property names: List[str]

Name of the view mode per return number

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

Prepares the key data and sets the image key to it.

Return type:

None

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

Prepares the key data and sets the cloud key to it.

Return type:

None

enabled(ls, return_num=0)[source]

Checks the view mode availability for a scan and return number

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

property name: str

Name of the view mode

property names: List[str]

Name of the view mode per return number

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

Prepares the key data and sets the image key to it.

Return type:

None

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

Prepares the key data and sets the cloud key to it.

Return type:

None

enabled(ls, return_num=0)[source]

Checks the view mode availability for a scan and return number

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

is_norm_reflectivity_mode(mode)[source]

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

Return type:

bool

LidarScanVizMode

Field view mode types

alias of Union[ImageCloudMode, ImageMode, CloudMode]

class CloudPaletteItem(name, palette)[source]

Bases: object

Palette with a name

name: str
palette: ndarray