Module ouster.sdk.viz
Ouster sensor data visualization tools. Implemented in C++ OpenGL and wrapped with Python bindings.
For additional information please refer to PointViz Tutorial & API Usage.
Core
- class PointViz
- add()
Add an object to the scene.
- Parameters
obj – A cloud, label, image or cuboid.
- property camera
Get a reference to the camera controls.
- pop_frame_buffer_handler()
Remove the last added callback for handling frame buffers data.
- push_frame_buffer_handler()
Add a callback for handling every frame buffer draw (super expensive).
- push_key_handler()
Add a callback for handling keyboard input.
- 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.
- property target_display
Get a reference to the target display.
- 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
- add_default_controls()
Add default keyboard and mouse bindings to a visualizer instance.
- class LidarScanViz(meta, viz=None)[source]
Visualize LidarScan data.
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
meta (
SensorInfo
) – sensor metadata used to interpret scansviz (
Optional
[PointViz
]) – use an existing PointViz instance instead of creating one
- cycle_cloud_mode()[source]
Change the channel field used to color the 3D point cloud.
- Return type
None
- property scan: ouster.client._client.LidarScan
The currently displayed scan.
- Return type
- run()[source]
Run the rendering loop of the visualizer.
See
PointViz.run()
- Return type
None
- class SimpleViz(arg, rate=None, _buflen=50)[source]
Visualize a stream of LidarScans.
Handles controls for playback speed, pausing and stepping.
- Parameters
arg (
Union
[SensorInfo
,LidarScanViz
]) – Metadata associated with the scans to be visualized or a LidarScanViz 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).
- Raises
ValueError – if the specified rate isn’t one of the options
- run(scans)[source]
Start reading scans and visualizing the stream.
Must be called from the main thread on macos. Will close the provided scan source before returning.
- Parameters
scans (
Iterable
[LidarScan
]) – A stream of scans to visualize.- Return type
None
- Returns
When the stream is consumed or the visualizer window is closed.
- viz.spezia_palette = spezia colors
- viz.calref_palette = calref colors
Visual Primitives
Cloud
for 3D Point Cloud
- class Cloud
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) -> None:
Unstructured point cloud for visualization.
Call set_xyz() to update
- Parameters
n – number of points
extrinsic – 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 the rotation and translation values per column.
- Parameters
rotation – array of exactly 9n where n is number of columns, so that the rotation of the ith column is
i
,i + 3n
,i + 6n
,i + n
,i + n + 3n
,i + n + 6n
,i + 2n
,i + 2n + 3n
,i + 2n + 6n
translation – array of exactly 3n where n is number of columns, so that the translation of the ith column is
i
,i + n
,i + 2n
- set_key()
Set the key values, used for colouring.
- Parameters
key – array of at least as many elements as there are points, preferably normalized between 0 and 1
- 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 exactly 3n where n is number of points, so that the xyz position of the ith point is
i
,i + n
,i + 2n
- property size
Number of points in a cloud
Image
for 2D image
- class Image
Manages the state of an image.
- 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.
- Parameters
image – 2D array with image data
- set_mask()
Set the RGBA mask.
- Parameters
mask – M x N x 4 array with RGBA mask
- 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
Cuboid
for 3D enclosure
- class Cuboid
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
Label
for 2D and 3D text
- class Label
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 labely – label 2D location in screen coords
[0..1]
, corresponding to top left corner of labelalign_right – if
True
- anchor point of the label is the right sidealign_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: ifTrue
- anchor point of the label is the right side align_top: ifTrue
- 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
Camera
and TargetDisplay
- class Camera
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.
Events WindowCtx
- class WindowCtx
Context for input callbacks.
- 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
- property viewport_height
Current viewport height in pixels
- property viewport_width
Current viewport width in pixels