vision3d.viz#
Optional 3D visualization utilities.
Requires the viz dependency group:
pip install vision3d[viz]
Functions
|
Build a 2D camera-panel grid from a dataset's rig metadata. |
|
Build a fusion-sample layout with a 3D view above a camera grid. |
|
Build a 3D view of the world entity tree. |
|
Log 3D bounding boxes to Rerun. |
|
Log all camera images with optional pinhole projection to Rerun. |
|
Log a point cloud to Rerun. |
|
Log a full sample dict to Rerun. |
- vision3d.viz.camera_grid(camera_names, grid=None, *, entity_prefix='world/cam', overlay_entities=('world/gt/boxes', 'world/pred/boxes'))[source]#
Build a 2D camera-panel grid from a dataset’s rig metadata.
Each cell in
gridis an index intocamera_names. Entity origins followlog_cameras’{entity_prefix}_{i}convention so this helper pairs directly withvision3d.viz.log_cameras().Panels are emitted row-major into a
Gridwithgrid_columnsset to the widest row.- Parameters:
camera_names (Sequence[str]) – Per-camera display names indexed by tensor position.
grid (Sequence[Sequence[int]] | None) – Row-major grid of indices into
camera_names.Noneif the dataset hasn’t declared a rig layout. Falls back to a single row in tensor order.entity_prefix (str) – Prefix for camera entity origins (e.g.
"world/cam"->/world/cam_0,/world/cam_1…).overlay_entities (Sequence[str] | None) – Box entities to overlay on every camera panel (e.g.
("world/gt/boxes", "world/pred/boxes")). All overlays are rendered as"majorwireframe"in the projections, since filled boxes would occlude the underlying image. PassNoneor an empty sequence to skip the overlay.
- Returns:
A
Gridcontaining oneSpatial2DViewper declared camera.- Raises:
ValueError – If any index is out of range for
camera_names.- Return type:
- vision3d.viz.fusion_layout(camera_names, grid=None, *, entity_prefix='world', row_shares=(3, 2), name=None)[source]#
Build a fusion-sample layout with a 3D view above a camera grid.
Composes
lidar_view()andcamera_grid()under matching entity prefixes that align withvision3d.viz.log_sample()’s defaults (world/cam_*for cameras,world/gt/boxesandworld/pred/boxesfor the box overlays).- Parameters:
camera_names (Sequence[str]) – Per-camera display names indexed by tensor position.
grid (Sequence[Sequence[int]] | None) – Row-major grid of indices into
camera_names. Seecamera_grid().entity_prefix (str) – Root entity prefix; the 3D view roots at
/{entity_prefix}, cameras at/{entity_prefix}/cam_*, box overlays at/{entity_prefix}/gt/boxesand/{entity_prefix}/pred/boxes.row_shares (Sequence[int]) – Vertical split ratio between the 3D view and camera grid.
name (str | None) – Optional display name.
- Returns:
A
Verticalcontainer stacking the 3D view and camera grid.- Return type:
- vision3d.viz.lidar_view(*, entity_prefix='world', name='3D')[source]#
Build a 3D view of the world entity tree.
The view captures everything under
/{entity_prefix}, typically the lidar point cloud, 3D boxes, and any logged camera frustums. Pairs withvision3d.viz.log_point_cloud()andvision3d.viz.log_sample().- Parameters:
- Returns:
A
Spatial3DViewrooted at/{entity_prefix}.- Return type:
- vision3d.viz.log_boxes_3d(entity, boxes, *, labels=None, class_ids=None, label_to_id=None, scores=None, score_threshold=None, fill_mode=None, show_labels=None, log_heading=True)[source]#
Log 3D bounding boxes to Rerun.
Logs boxes as
rr.Boxes3Dand optionally heading arrows asrr.Arrows3Don a/headingsub-entity. Designed to serve both ground-truth and prediction boxes: route each to its own entity (e.g."world/gt/boxes"vs"world/pred/boxes") and distinguish them visually withfill_modewhile keeping per-class colors.- Parameters:
entity (str) – Rerun entity path (e.g.
"world/gt/boxes").boxes (BoundingBoxes3D) – Bounding boxes in any supported format.
labels (list[str] | None) – Per-box label strings for display. When
scoresis given, the score is appended to each label.class_ids (list[int] | None) – Per-box class IDs for coloring via AnnotationContext.
label_to_id (dict[str, int] | None) – Mapping from class name to class ID. When provided, an
rr.AnnotationContextis logged statically on the entity soclass_idsresolve to consistent colors and display names across frames.scores (list[float] | Tensor | None) – Per-box confidence scores. When given, each box label shows its score (e.g.
"car 0.87").score_threshold (float | None) – If set, boxes with
scoresbelow this value are dropped before logging. Requiresscores.fill_mode (FillMode | Literal['DenseWireframe', 'MajorWireframe', 'Solid', 'TransparentFillMajorWireframe', 'densewireframe', 'majorwireframe', 'solid', 'transparentfillmajorwireframe'] | int | None) – Box fill mode (e.g.
"majorwireframe","densewireframe","solid").show_labels (bool | None) – Force per-box labels on (
True) or off (False) in the viewer.Noneleaves Rerun’s default heuristic, which hides labels when there are many boxes.log_heading (bool) – If True and boxes have rotation, log heading arrows.
- Raises:
ValueError – If
score_thresholdis set withoutscores, or ifscores,labels, orclass_idslength does not match the number of boxes.- Return type:
None
- vision3d.viz.log_cameras(entity_prefix, images, intrinsics=None, extrinsics=None, *, jpeg_quality=None)[source]#
Log all camera images with optional pinhole projection to Rerun.
Each camera is logged to
{entity_prefix}_{i}.- Parameters:
entity_prefix (str) – Rerun entity path prefix (e.g.
"world/cam").images (CameraImages | Tensor) – Camera images
[N_cams, C, H, W].intrinsics (CameraIntrinsics | Tensor | None) – Intrinsic matrices
[N_cams, 3, 3].extrinsics (CameraExtrinsics | Tensor | None) – Extrinsic matrices
[N_cams, 4, 4](lidar-to-camera).jpeg_quality (int | None) – If set, JPEG-encode each image at this quality (0-100) before logging.
None(default) logs uncompressed.
- Return type:
None
- vision3d.viz.log_point_cloud(entity, points, *, color_by_distance=True)[source]#
Log a point cloud to Rerun.
- Parameters:
entity (str) – Rerun entity path (e.g.
"world/lidar").points (PointCloud3D | Tensor) – Point cloud
[N, 3+C]. First 3 columns are xyz.color_by_distance (bool) – Color points by distance from origin.
- Return type:
None
- vision3d.viz.log_sample(inputs, targets=None, *, predictions=None, entity_prefix='world', label_to_id=None, score_threshold=None, jpeg_quality=None)[source]#
Log a full sample dict to Rerun.
Convenience function that dispatches to type-specific loggers. Ground truth and predictions are logged to separate entities (
{entity_prefix}/gt/boxesand{entity_prefix}/pred/boxes) so they can be toggled independently; both keep per-class colors and are distinguished by fill style (ground truth as translucent colored faces, predictions as a wireframe).- Parameters:
inputs (SampleInputs) –
SampleInputswith"points","images","extrinsics","intrinsics"keys.targets (SampleTargets | None) – Optional
SampleTargetswith"boxes","labels"keys (ground truth).predictions (Prediction3D | None) – Optional
Prediction3Dwith"boxes","scores","labels"keys. Prediction labels show their score.entity_prefix (str) – Rerun entity path prefix.
label_to_id (dict[str, int] | None) – Mapping from class name to class ID for consistent coloring. Build this across all frames before logging.
score_threshold (float | None) – If set, predictions below this score are dropped.
jpeg_quality (int | None) – If set, JPEG-encode camera images at this quality (0-100) before logging. See
log_cameras().
- Return type:
None