1 utils.plotting.snippet
utils.plotting.snippet
Build Plotly views of EFM snippet geometry and trajectories.
This module owns the cohesive 3D snippet presentation transaction: pose lookup, semidense selection, mesh and box traces, snippet-relative bounds, and Plotly frusta. Its frustum kernel intentionally remains here: it uses normalized rays through an inscribed valid-radius square, while Rerun uses image corners at camera-z depth. Merging those policy-specific constructions would change the figures’ geometry.
1.1 Classes
| Name | Description |
|---|---|
| SnippetPlotBuilder | Composable builder for mesh/points/frusta visuals using a stored snippet. |
1.1.1 SnippetPlotBuilder
utils.plotting.snippet.SnippetPlotBuilder(snippet, *, title, height=900)Composable builder for mesh/points/frusta visuals using a stored snippet.
All data comes from the snippet; methods only accept visual/customisation params.
1.1.1.1 Methods
| Name | Description |
|---|---|
| from_snippet | Create a builder whose initial bounds cover the snippet evidence. |
| add_mesh | Add the snippet’s world-frame GT mesh when one is loaded. |
| add_semidense | Add sampled world-frame semi-dense points colored by world height. |
| add_semidense_in_oriented_box | Add semidense points cropped by a world-frame oriented box. |
| add_points | Scatter arbitrary 3D points onto the figure and update bounds. |
| add_trajectory | Add the world-frame rig trajectory and optional endpoint markers. |
| add_frusta | Add camera frusta aligned to nearest rig trajectory timestamps. |
| add_frame_axes | Add axes for a camera stream or the rig itself. |
| add_camera_axes | Add axes for a named camera stream through add_frame_axes. |
| add_frame_axes_to_fig | Add LUF axes for multiple cameras in one go. |
| add_oriented_box_corners | Add one or more oriented boxes from world-frame corners. |
| add_oriented_box | Add an oriented box from a world<-object pose and XYZ side lengths. |
| add_obb | Add one or more ObbTW boxes using their world-frame corners. |
| add_bounds_box | Draw an axis-aligned world-frame bounds box in metres. |
| add_gt_obbs | Add oriented boxes defined by world←object poses and dimensions. |
| finalize | Apply equal world-axis scaling and return the accumulated figure. |
1.1.1.1.1 from_snippet
utils.plotting.snippet.SnippetPlotBuilder.from_snippet(
snippet,
*,
title,
height=900,
)Create a builder whose initial bounds cover the snippet evidence.
1.1.1.1.2 add_mesh
utils.plotting.snippet.SnippetPlotBuilder.add_mesh(
color='lightgray',
opacity=0.35,
)Add the snippet’s world-frame GT mesh when one is loaded.
1.1.1.1.3 add_semidense
utils.plotting.snippet.SnippetPlotBuilder.add_semidense(
name='Semidense points',
max_points=20000,
last_frame_only=True,
color='Viridis',
)Add sampled world-frame semi-dense points colored by world height.
The point tensor has logical shape Tensor["N 3", float32] in metres. Sampling affects display density only and never mutates the :class:EfmSnippetView.
1.1.1.1.4 add_semidense_in_oriented_box
utils.plotting.snippet.SnippetPlotBuilder.add_semidense_in_oriented_box(
pose_world_object,
extents,
name='Target semidense points',
max_points=20000,
last_frame_only=False,
color='gold',
size=3,
opacity=0.8,
)Add semidense points cropped by a world-frame oriented box.
1.1.1.1.5 add_points
utils.plotting.snippet.SnippetPlotBuilder.add_points(
points,
*,
name='Points',
color='royalblue',
size=4,
opacity=0.7,
symbol='circle',
)Scatter arbitrary 3D points onto the figure and update bounds.
1.1.1.1.6 add_trajectory
utils.plotting.snippet.SnippetPlotBuilder.add_trajectory(
mark_first_last=True,
first_color='green',
last_color='red',
show=True,
)Add the world-frame rig trajectory and optional endpoint markers.
1.1.1.1.7 add_frusta
utils.plotting.snippet.SnippetPlotBuilder.add_frusta(
camera='rgb',
frame_indices=None,
scale=1.0,
include_axes=True,
include_center=True,
is_rotate_yaw_cw90=True,
name='Frustum',
)Add camera frusta aligned to nearest rig trajectory timestamps.
Poses follow \(T_{world\leftarrow camera}=T_{world\leftarrow rig} T^{-1}_{camera\leftarrow rig}\). The clockwise display rotation is a visualization convention and does not change stored camera geometry.
1.1.1.1.8 add_frame_axes
utils.plotting.snippet.SnippetPlotBuilder.add_frame_axes(
frame='rgb',
frame_indices=None,
title='Frame axes',
is_rotate_yaw_cw90=True,
)Add axes for a camera stream or the rig itself.
1.1.1.1.8.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| frame | Literal['rgb', 'slaml', 'slamr', 'rig'] | PoseTW |
Camera label, “rig” for the rig frame to retrieve the poses form sample.trajectory, or a custom PoseTW. |
'rgb' |
1.1.1.1.9 add_camera_axes
utils.plotting.snippet.SnippetPlotBuilder.add_camera_axes(
camera='rgb',
frame_indices=None,
title='Camera axes',
)Add axes for a named camera stream through add_frame_axes.
1.1.1.1.10 add_frame_axes_to_fig
utils.plotting.snippet.SnippetPlotBuilder.add_frame_axes_to_fig(
fig,
cam_centers,
cam_axes,
title='Camera axes',
scale=1.0,
)Add LUF axes for multiple cameras in one go.
1.1.1.1.11 add_oriented_box_corners
utils.plotting.snippet.SnippetPlotBuilder.add_oriented_box_corners(
corners_world,
*,
name,
color,
width=5,
opacity=0.95,
)Add one or more oriented boxes from world-frame corners.
1.1.1.1.12 add_oriented_box
utils.plotting.snippet.SnippetPlotBuilder.add_oriented_box(
pose_world_object,
extents,
name,
color,
width=5,
opacity=0.95,
)Add an oriented box from a world<-object pose and XYZ side lengths.
1.1.1.1.13 add_obb
utils.plotting.snippet.SnippetPlotBuilder.add_obb(
obb,
*,
name,
color,
width=5,
opacity=0.95,
)Add one or more ObbTW boxes using their world-frame corners.
1.1.1.1.14 add_bounds_box
utils.plotting.snippet.SnippetPlotBuilder.add_bounds_box(
name,
color='gray',
dash='dash',
width=2,
aabb=None,
)Draw an axis-aligned world-frame bounds box in metres.
1.1.1.1.15 add_gt_obbs
utils.plotting.snippet.SnippetPlotBuilder.add_gt_obbs(
camera='rgb',
timestamp=None,
color='purple',
name='GT OBBs',
opacity=0.35,
)Add oriented boxes defined by world←object poses and dimensions.
1.1.1.1.16 finalize
utils.plotting.snippet.SnippetPlotBuilder.finalize()Apply equal world-axis scaling and return the accumulated figure.
1.2 Functions
| Name | Description |
|---|---|
| add_pose_axes_to_figure | Add RGB coordinate triads for one or more pose centers to a Plotly figure. |
| bbox_edges | Return AABB wireframe segments as (2, 3) arrays in Plotly order. |
| configure_3d_scene | Apply equal-scale 3D axes and an optional bounded scene range. |
| get_frustum_segments | Return frustum wireframe segments in world frame using CameraTW.unproject. |
| mesh_to_plotly | Convert a Trimesh to Plotly Mesh3d traces. |
| plot_trajectory | Mesh + semidense + trajectory + optional frusta/bounds. |
| pose_world_cam | Return the world<-camera pose and camera intrinsics for a given frame. |
| semidense_points_for_frame | Collect semidense points for one frame or the full snippet. |
1.2.1 add_pose_axes_to_figure
utils.plotting.snippet.add_pose_axes_to_figure(
fig,
centers,
axes,
*,
title='Pose axes',
scale=1.0,
line_width=8,
)Add RGB coordinate triads for one or more pose centers to a Plotly figure.
This is deliberately independent of :class:EfmSnippetView: callers own their pose decoding and provide finite (N, 3) centers plus ordered local X/Y/Z directions of shape (N, 3, 3). It is the shared 3D presentation seam used by snippet and persisted-rollout diagnostics.
1.2.2 bbox_edges
utils.plotting.snippet.bbox_edges(min_pt, max_pt)Return AABB wireframe segments as (2, 3) arrays in Plotly order.
1.2.2.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| min_pt | np.ndarray |
XYZ lower bounds (metres) for the axis-aligned box. | required |
| max_pt | np.ndarray |
XYZ upper bounds (metres) for the axis-aligned box. | required |
1.2.2.2 Returns
| Name | Type | Description |
|---|---|---|
np.ndarray |
Array of shape (12, 2, 3) ready for Scatter3d. The edge ordering |
|
np.ndarray |
matches the efm3d frustum/box helpers to keep consistent legend/colour | |
np.ndarray |
usage when overlaying boxes. |
1.2.3 configure_3d_scene
utils.plotting.snippet.configure_3d_scene(
fig,
*,
title=None,
height=None,
axis_titles=('X', 'Y', 'Z'),
scene_ranges=None,
)Apply equal-scale 3D axes and an optional bounded scene range.
The helper does not interpret coordinates or convert units. Callers pass axis labels appropriate to their already-decoded frame, for example metres for snippets or target-distance units for rollout geometry.
1.2.4 get_frustum_segments
utils.plotting.snippet.get_frustum_segments(cam, pose_world_cam, scale=1.0)Return frustum wireframe segments in world frame using CameraTW.unproject.
The four image-plane corners are first unprojected in the camera’s intrinsic frame, then transformed to world frame using pose_world_cam.
1.2.5 mesh_to_plotly
utils.plotting.snippet.mesh_to_plotly(mesh)Convert a Trimesh to Plotly Mesh3d traces.
1.2.6 plot_trajectory
utils.plotting.snippet.plot_trajectory(
sample,
camera='rgb',
show_semidense=True,
max_sem_points=20000,
pc_from_last_only=True,
show_scene_bounds=True,
show_crop_bounds=False,
crop_aabb=None,
show_frustum=True,
frustum_frame_indices=None,
frustum_scale=1.0,
mark_first_last=True,
show_gt_obbs=False,
gt_timestamp=None,
)Mesh + semidense + trajectory + optional frusta/bounds.
1.2.7 pose_world_cam
utils.plotting.snippet.pose_world_cam(sample, cam_view, frame_idx)Return the world<-camera pose and camera intrinsics for a given frame.
1.2.8 semidense_points_for_frame
utils.plotting.snippet.semidense_points_for_frame(
sample,
frame_idx,
*,
all_frames,
)Collect semidense points for one frame or the full snippet.