Skip to content

Scene Calls

The scene calls of the caliper package log 3-D and 2-D geometry into a scene that every viewer of the network route draws.

Scene Model

A scene is a live view of 3-D or 2-D geometry: a tree of entities, named by entity paths such as "world/cloud", each holding batches of points, lines, arrows, boxes, a mesh or an image, or a pinhole camera, and each placed by an entity transform. Scenes travel on the network route only, over caliper.serve() and a hub that it connects to, with the Wire Protocol 3.2 draft. With only the live session or the in-process window open, the first scene call warns once and scene calls do nothing there. The Caliper app and caliper-viewer attached to the stream (Viewer), the notebook widget and the viewer page draw a scene with the same scene view on the GPU; in a browser it needs WebGPU and Caliper's WebAssembly views, and without them the scene's plate shows a notice in its place. The scene view draws points, lines (segments and strips) and meshes so far; for the other parts and arguments it says what it does not draw yet (Versioning).

scene = caliper.scene("world", up="+z", view_camera={"target": (0, 0, 0.5), "azimuth": 30.0})
scene.classes({0: "floor", 1: "obstacle"})
scene.points("room/cloud", xyz, class_ids=(xyz[:, 2] > 0.05).int(), static=True)
scene.transform("rig/left", translation=(-0.06, -2.5, 1.2), rotation=forward_y, static=True)
scene.camera("rig/left", width=640, height=480, focal=525.0, static=True)
scene.image("rig/left/rgb", frame)                      # in the camera's pixel space
scene.lines("graph/edges", pos, indices=edge_index.T, values=weight, cmap="magma")
caliper.widget("world", "scene", height=480)

scene

scene(
    name: str = "scene",
    *,
    space: str = "3d",
    up=None,
    units: str = "m",
    rate=None,
    data_view=None,
    view_camera=None,
) -> "Scene"

Make or fetch the scene name, a tree of entities that every viewer of the network route draws.

A scene holds entities, named by entity paths such as "world/cloud". Each entity holds batches of points, lines, arrows, boxes, a mesh or an image, or a pinhole camera, and an entity transform places it. The space is 3-D or 2-D, fixed when the scene is made. Log to the returned Scene with its points, lines, arrows, boxes, mesh, image, depth, segmentation, camera, transform, classes and clear methods (Scene Calls).

Scenes travel over serve: the notebook widget with kind="scene", the browser page and a hub. With only the shared-memory session or the in-process window open, a scene call warns once and does nothing there. The scene module is imported on first use, so importing caliper stays light.

A second call with the same name returns the same scene and updates up, units, rate and view_camera. up, units and rate are set from the arguments of that call, so an omitted one returns to its default. view_camera=None leaves the starting camera as it is, and view_camera={} returns it to the fit.

Arguments

Name Type Description Default
name str

The scene id: 1 to 63 bytes, with no ##.

'scene'
space str

"3d" or "2d". Positions are (N, 3) in a 3-D scene and (N, 2) in a 2-D one. A scene keeps its space.

'3d'
up str | None

In 3-D, the axis a view keeps upright when it opens, from "+x" to "-z". In 2-D, the direction of y on screen, "-y" or "+y". None is "+y" in 3-D and "-y" in 2-D.

None
units str

A note of at most 15 bytes shown with the view. Nothing is converted.

'm'
rate float | None

The default rate limit of each batch, in snapshots per second. None is 60 per second, and 0 means every call (Rate Limits).

None
data_view dict | None

Not built yet.

None
view_camera dict | str | None

The camera a 3-D view opens on: a dict with any of target (3 numbers), distance (above 0), azimuth and elevation (degrees, from -89 to 89), or the entity path of a camera to look through. Keys left out are filled from the fit.

None

Returns

Type Description
Scene

The scene.

Raises

Type Description
ValueError

When name, space, up or units is invalid, rate is negative or not finite, view_camera has an unknown key, a number that is not finite, a distance not above 0, an elevation outside -89 to 89 or a path outside the entity path grammar, or view_camera is given in a 2-D scene, or space differs from the space of the existing scene.

TypeError

When rate is not a number, or view_camera is neither a dict nor a string, or one of its values has the wrong type.

NotImplementedError

When data_view is given.

Like every view call, the first call of a script opens the live session when no route is open. The view shows units on its scale bar, with an SI prefix for m, s and g, and units="" shows the number alone. The starting camera travels in the scene's entry in VIEWS, and a view moves to a new one only until a person moves its camera. caliper.remove(name) removes the scene and what it retains, and caliper.widget(name, "scene") shows it in a notebook.

Primitives

Each call logs one part of the entity at path and replaces the batch that part held. The empty path is the scene's root, which may hold batches too. A call returns True when a route took a snapshot and False when none did: no viewer of the scene is attached, or the batch's rate limit dropped it.

The arguments of each call are in the Scene reference below.

The rows of colors and values are N for points and arrows, V, S or E for lines, and V for a mesh. colors and values together raise ValueError, and so do a shape, dtype or row count that does not fit, a bad path, an odd number of segment vertices, strip lengths that do not add up (when they are host data), indices with strip_lengths, uvs without texture, rotations of 2-D boxes, a mesh without indices whose vertex count is not a multiple of 3, a batch over the limits (4,194,304 points, vertices, edges or triangles, 1,048,576 arrows, boxes or strips, images of 8,192 pixels on a side, 1,024 entities and 2,048 batches in a scene), and a part the entity cannot hold: a primitive at an entity that holds a camera, 3-D data under a camera, whose children live in its 2-D pixel space, and in a 3-D scene an image that is not under a camera logged before it. These checks read host metadata only, so they run on every call, attached or not. An argument of the wrong type raises TypeError. Strip lengths in a device tensor are checked once their copy reaches host memory, on the network thread: a batch whose lengths do not add up to V, or hold a length below 1, is dropped there with a warning, and the call has already returned True. items=, blend= and the instance arrays of a mesh are not built yet and raise NotImplementedError, for example items= is not built yet (picking and linked selection).

Call Cost

With no viewer of the scene attached, a call costs its checks and a dictionary update and does no device work, unless the batch is static. With a viewer attached and the batch due, the snapshot is built once on the arrays' own device: the casts, colours as RGBA, 2-D box corners turned into centres, the per-axis bounds and the value range (sent as stats; a depth image's range leaves out zeros and non-finite depths), and the budget of the default data view, which samples more than 100,000 points or segments by stride. Each array is then copied into pinned host memory without waiting, one torch.mps.Event is recorded, and the network thread reads the copies once the event has completed. Nothing reads the device on the training thread. Each resource above 8 MiB travels in RESOURCE parts. A batch above 512 MiB raises ValueError.

Piece Form

The Caliper app, caliper-viewer, and WebAssembly views announce scene_pieces. Every drawable part uses its library piece. The network thread packs host arrays into RESOURCE messages, then sends the update that names them. It packs each batch once and shares the bytes across subscriptions. A newer batch can replace an unsent batch before this work starts.

Points, lines, arrows, boxes, meshes, color images, depth images, and segmentation images use this form. Mesh textures travel as texture resources. The network thread decodes bounded PNG and JPEG images with Pillow, then sends RGBA texture resources. The training thread does not decode images or pack resources.

A viewer without scene_pieces receives cameras, transforms, class tables, and clears. It receives no drawable batches. Saved per-shape updates remain readable through the recording converter. See Piece Form for resource layouts and source metadata.

Static Items

A batch logged with static=True is copied once at the call, even with nothing attached, and the producer retains it, a newer static batch of the same entity part replacing it. The rate limit never drops one. A batch logged without static is snapshotted only while a viewer watches the scene; the producer keeps the newest one it sent of each entity part.

Rate Limits

Each batch, an entity path and part, has its own rate limit (rate, else the scene's, else 60 per second), and a viewer's max_rate applies to each entity part of its subscription, the newest batch replacing one still waiting.

Cameras, Entity Transforms, Class Table and Clears

The arguments of camera, transform, classes and clear are in the Scene reference below.

A camera sits at an entity of its own, posed by that entity's transform; the entity holds no primitive, the root holds no camera, and a camera is never under another. Its children live in its pixel space, where images, 2-D points, lines, arrows and boxes sit. An entity transform of tensors is composed on their device and copied without waiting, as an array is; one of numbers is composed on the host. A clear removes the entity's primitives, camera and transform, and its subtree's with recursive; static parts stay unless the clear is static too, and clear("", recursive=True) empties the scene's live data. These four calls are small: the producer keeps them whether or not a viewer is attached, the rate limit never drops them, a clear applies at once to what it keeps, and each returns True. A viewer's pending entity transforms merge into one message, the newest of each entity.

Late Viewers

When a viewer subscribes to a scene, it first receives the scene's state: a reset, the class table, the static and then the other entity transforms, then every camera, every static batch and the newest batch of every other entity part, in the byte order of their paths. It draws an entity whose batch was not kept from its next call.

Scene

A scene of entities, drawn in one 3-D or 2-D space, returned by scene.

Each entity holds batches of primitives, a camera or an entity transform. A primitive call (points, lines, arrows, boxes, mesh, image, depth, segmentation) logs one part of one entity and returns True if a route took a snapshot. It returns False when every route skipped it: nothing is attached, or the rate limit dropped it. camera, transform, classes and clear are kept whether or not anything is attached, and return True.

Every call checks its arguments from host metadata only, so a bad call raises at once, attached or not (Scene Calls). A call on a scene that remove dropped makes it again, empty. Only serve and a hub that it connects to carry scenes; with only the shared-memory session or the in-process window open, a scene call warns once and does nothing there. data_view=, items=, blend= and the instance arrays of a mesh are not built yet and raise NotImplementedError.

Attributes

Name Type Description
name str

The scene id.

space str

"3d" or "2d".

up str

The axis a 3-D view keeps upright, or the direction of y in 2-D.

units str

The unit note shown with the view.

rate float | None

The default rate limit of each batch, None for 60 per second.

view_camera dict | str | None

The camera a 3-D view opens on, None for the fit.

points

points(
    path,
    positions,
    *,
    colors=None,
    values=None,
    cmap="viridis",
    vmin=None,
    vmax=None,
    class_ids=None,
    radii=None,
    labels=None,
    items=None,
    blend="normal",
    static=False,
    rate=None,
) -> bool

Log a batch of points at entity path, replacing the points it held.

Points are drawn as discs of a few pixels unless radii is given. Give at most one of colors and values. A static batch is the setup of the scene (Static Items).

Arguments

Name Type Description Default
path str

The entity path: 0 to 16 segments of [A-Za-z0-9_.-]{1,63} joined by /, at most 255 bytes. The empty string is the root.

required
positions Tensor | ndarray | Sequence

Positions (N, D), with D 3 in a 3-D scene and 2 in a 2-D scene or under a camera. At most 4,194,304 points.

required
colors Tensor | tuple | None

Colors (N, 3) or (N, 4) as uint8 or floats in [0, 1], or one color for all as a tuple of 3 or 4 integers from 0 to 255 or floats from 0 to 1. A missing alpha is 255.

None
values Tensor | None

Values (N,) drawn through cmap.

None
cmap str | int

"viridis", "magma" or "rdbu", or 0, 1 or 2.

'viridis'
vmin float | None

Fixed lower end of the value range. None computes that end on the device. Each end is independent.

None
vmax float | None

Fixed upper end of the value range, as for vmin.

None
class_ids Tensor | None

Integer class ids (N,), colored by the class table of classes.

None
radii Tensor | float | None

Radii (N,) or one number above 0, in scene units.

None
labels str | Sequence[str] | None

One label for all points, or one per point. Each is at most 63 bytes, and at most 4,096 labels.

None
items None

Not built yet (picking and linked selection).

None
blend str

Only "normal". Additive blending is not built yet.

'normal'
static bool

Copy the batch once at the call and retain it for every viewer.

False
rate float | None

Snapshots per second for this batch. None takes the rate of the scene (Rate Limits).

None

Returns

Type Description
bool

True if a route took a snapshot, False if every route skipped it.

Raises

Type Description
TypeError

When path is not a string, static is not a bool, or an argument has the wrong type.

ValueError

When path is not an entity path, colors and values are given together, a shape, dtype or row count does not fit, a batch is over the limits, the entity cannot hold points, or the scene is at its limit of 1,024 entities or 2,048 batches.

NotImplementedError

When items or blend is not its default.

lines

lines(
    path,
    positions,
    *,
    indices=None,
    strip_lengths=None,
    colors=None,
    values=None,
    cmap="viridis",
    vmin=None,
    vmax=None,
    color_per=None,
    width=2.0,
    blend="normal",
    static=False,
    rate=None,
) -> bool

Log a batch of lines at entity path, replacing the lines it held.

positions holds the vertices. Without indices and strip_lengths, vertices 2k and 2k + 1 form segment k. With strip_lengths, consecutive vertices form strips. With indices, each row is an edge between two vertices, as PyTorch Geometric's edge_index.T.

Colors belong to the vertices, the strips or the edges. color_per says which; None reads it from the row count of colors or values, and a count that fits two raises ValueError.

Arguments

Name Type Description Default
path str

The entity path, as for points.

required
positions Tensor | ndarray | Sequence

Vertices (V, D), with D 3 in a 3-D scene and 2 in a 2-D scene or under a camera. At most 4,194,304 vertices. Segments need an even V.

required
indices Tensor | None

Integer index pairs (E, 2), at most 4,194,304 edges. A (2, E) array raises ValueError and names the fix. Not together with strip_lengths.

None
strip_lengths Sequence[int] | Tensor | None

The vertices of each strip, (S,), at least 1 each and adding up to V, at most 1,048,576 strips. Lengths in a device tensor are checked once their copy reaches host memory; a batch that fails there is dropped with a warning, after the call returned True.

None
colors Tensor | tuple | None

Colors (rows, 3) or (rows, 4) as uint8 or floats in [0, 1], or one color for all, as for points. The rows are V, S or E.

None
values Tensor | None

Values (rows,) drawn through cmap. Not together with colors.

None
cmap str | int

"viridis", "magma" or "rdbu", or 0, 1 or 2.

'viridis'
vmin float | None

Fixed lower end of the value range. None computes that end on the device.

None
vmax float | None

Fixed upper end of the value range, as for vmin.

None
color_per str | None

"vertex", "strip" or "edge". "strip" needs strip_lengths and "edge" needs indices.

None
width float

Line width in pixels, above 0.

2.0
blend str

Only "normal". Additive blending is not built yet.

'normal'
static bool

Copy the batch once at the call and retain it for every viewer.

False
rate float | None

Snapshots per second for this batch. None takes the rate of the scene.

None

Returns

Type Description
bool

True if a route took a snapshot, False if every route skipped it.

Raises

Type Description
TypeError

When path is not a string, static is not a bool, or an argument has the wrong type.

ValueError

When path is not an entity path, color_per is unknown or does not fit the batch, indices and strip_lengths are given together, the vertex count is odd for segments, the strip lengths do not add up to V (when they are host data) or one is below 1, colors and values are given together, a shape, dtype or row count does not fit, a batch is over the limits, the entity cannot hold lines, or the scene is at its limit of 1,024 entities or 2,048 batches.

NotImplementedError

When blend is not "normal".

arrows

arrows(
    path,
    origins,
    vectors,
    *,
    colors=None,
    values=None,
    cmap="viridis",
    vmin=None,
    vmax=None,
    width=2.0,
    static=False,
    rate=None,
) -> bool

Log a batch of arrows at entity path, replacing the arrows it held.

Each arrow starts at an origin and runs along its vector. The head is a fifth of the length. Colors work as for points.

Arguments

Name Type Description Default
path str

The entity path, as for points.

required
origins Tensor | ndarray | Sequence

Origins (N, D), with D 3 in a 3-D scene and 2 in a 2-D scene or under a camera. At most 1,048,576 arrows.

required
vectors Tensor | ndarray | Sequence

Vectors (N, D), with the shape of origins.

required
colors Tensor | tuple | None

Colors (N, 3) or (N, 4), or one color for all.

None
values Tensor | None

Values (N,) drawn through cmap. Not together with colors.

None
cmap str | int

"viridis", "magma" or "rdbu", or 0, 1 or 2.

'viridis'
vmin float | None

Fixed lower end of the value range. None computes that end on the device.

None
vmax float | None

Fixed upper end of the value range, as for vmin.

None
width float

Arrow width in pixels, above 0.

2.0
static bool

Copy the batch once at the call and retain it for every viewer.

False
rate float | None

Snapshots per second for this batch. None takes the rate of the scene.

None

Returns

Type Description
bool

True if a route took a snapshot, False if every route skipped it.

Raises

Type Description
TypeError

When path is not a string, static is not a bool, or an argument has the wrong type.

ValueError

When path is not an entity path, vectors does not have the shape of origins, colors and values are given together, a shape, dtype or row count does not fit, a batch is over the limits, the entity cannot hold arrows, or the scene is at its limit of 1,024 entities or 2,048 batches.

boxes

boxes(
    path,
    centers=None,
    half_sizes=None,
    *,
    corners=None,
    rotations=None,
    colors=None,
    class_ids=None,
    labels=None,
    fill=False,
    width=2.0,
    items=None,
    static=False,
    rate=None,
) -> bool

Log a batch of boxes at entity path, replacing the boxes it held.

Give centers and half_sizes, or in 2-D corners. A 3-D box may be rotated. Edges are drawn with width, and fill adds translucent faces.

Arguments

Name Type Description Default
path str

The entity path, as for points.

required
centers Tensor | ndarray | Sequence | None

Centers (N, D), with D 3 in a 3-D scene and 2 in a 2-D scene or under a camera. At most 1,048,576 boxes.

None
half_sizes Tensor | ndarray | Sequence | None

Half sizes (N, D), with the shape of centers.

None
corners Tensor | None

2-D boxes (N, 4) as (x0, y0, x1, y1), converted to centers and half sizes on the device. Replaces centers and half_sizes.

None
rotations Tensor | None

Quaternions (N, 4) as x y z w, for 3-D boxes only.

None
colors Tensor | tuple | None

Colors (N, 3) or (N, 4), or one color for all.

None
class_ids Tensor | None

Integer class ids (N,), colored by the class table of classes.

None
labels str | Sequence[str] | None

One label for all boxes, or one per box. Each is at most 63 bytes, and at most 4,096 labels.

None
fill bool

Also draw translucent faces.

False
width float

Edge width in pixels, above 0.

2.0
items None

Not built yet (picking and linked selection).

None
static bool

Copy the batch once at the call and retain it for every viewer.

False
rate float | None

Snapshots per second for this batch. None takes the rate of the scene.

None

Returns

Type Description
bool

True if a route took a snapshot, False if every route skipped it.

Raises

Type Description
TypeError

When path is not a string, static is not a bool, fill is not a bool, neither corners nor both centers and half_sizes are given, or an argument has the wrong type.

ValueError

When path is not an entity path, corners is given together with centers or half_sizes or in a 3-D space, rotations is given in 2-D or does not fit, a shape, dtype or row count does not fit, a batch is over the limits, the entity cannot hold boxes, or the scene is at its limit of 1,024 entities or 2,048 batches.

NotImplementedError

When items is given.

mesh

mesh(
    path,
    positions,
    indices=None,
    *,
    normals=None,
    colors=None,
    values=None,
    cmap="viridis",
    vmin=None,
    vmax=None,
    uvs=None,
    texture=None,
    instance_poses=None,
    instance_colors=None,
    instance_values=None,
    static=False,
    rate=None,
) -> bool

Log a triangle mesh at entity path, replacing the mesh it held.

Without indices, each three vertices form a triangle. Faces are flat without normals. The color comes from one of colors, values, or uvs with a texture. An index out of range draws as the last vertex.

Arguments

Name Type Description Default
path str

The entity path, as for points.

required
positions Tensor | ndarray | Sequence

Vertices (V, D), with D 3 in a 3-D scene and 2 in a 2-D scene or under a camera. At most 4,194,304 vertices. Without indices, V is a multiple of 3.

required
indices Tensor | None

Triangles (T, 3) in any integer dtype, at most 4,194,304.

None
normals Tensor | None

Per-vertex normals (V, 3) for smooth shading.

None
colors Tensor | tuple | None

Per-vertex colors (V, 3) or (V, 4), or one color for all.

None
values Tensor | None

Per-vertex values (V,) drawn through cmap.

None
cmap str | int

"viridis", "magma" or "rdbu", or 0, 1 or 2.

'viridis'
vmin float | None

Fixed lower end of the value range. None computes that end on the device.

None
vmax float | None

Fixed upper end of the value range, as for vmin.

None
uvs Tensor | None

Texture coordinates (V, 2). Given together with texture, and instead of colors and values.

None
texture Tensor | None

A texture (H, W, 3) or (H, W, 4), uint8 or floats in [0, 1], at most 8,192 pixels on a side.

None
instance_poses None

Not built yet (instanced meshes).

None
instance_colors None

Not built yet (instanced meshes).

None
instance_values None

Not built yet (instanced meshes).

None
static bool

Copy the batch once at the call and retain it for every viewer.

False
rate float | None

Snapshots per second for this batch. None takes the rate of the scene.

None

Returns

Type Description
bool

True if a route took a snapshot, False if every route skipped it.

Raises

Type Description
TypeError

When path is not a string, static is not a bool, or an argument has the wrong type.

ValueError

When path is not an entity path, a mesh without indices has a vertex count that is not a multiple of 3, uvs and texture are not given together or are given with colors or values, colors and values are given together, a shape, dtype or row count does not fit, a batch is over the limits, the entity cannot hold a mesh, or the scene is at its limit of 1,024 entities or 2,048 batches.

NotImplementedError

When an instance argument is given.

image

image(path, image, *, opacity=1.0, static=False, rate=None) -> bool

Log a color image at entity path, replacing the image it held.

In a 3-D scene an image sits under a camera, in its pixel space, so log the camera at a parent of path first.

Arguments

Name Type Description Default
path str

The entity path, as for points.

required
image Tensor | ndarray | bytes

A tensor (H, W, 3), (H, W, 4) or (H, W) as uint8 or floats in [0, 1] (floats are converted on the device), at most 8,192 pixels on a side. Or the bytes of one JPEG or PNG frame, recognised by its signature, of at most 16 MiB.

required
opacity float

From 0 to 1.

1.0
static bool

Copy the batch once at the call and retain it for every viewer.

False
rate float | None

Snapshots per second for this batch. None takes the rate of the scene.

None

Returns

Type Description
bool

True if a route took a snapshot, False if every route skipped it.

Raises

Type Description
TypeError

When path is not a string, static is not a bool, or an argument has the wrong type.

ValueError

When path is not an entity path, opacity is outside 0 to 1, the bytes are not one JPEG or PNG frame or are over 16 MiB, the shape or dtype does not fit, the image is over 8,192 pixels on a side, the entity cannot hold an image (in a 3-D scene, one that is not under a camera), or the scene is at its limit of 1,024 entities or 2,048 batches.

depth

depth(
    path,
    depth,
    *,
    scale=None,
    cmap="viridis",
    vmin=None,
    vmax=None,
    cloud=None,
    static=False,
    rate=None,
) -> bool

Log a depth image at entity path, replacing the image it held.

A depth image is an image part, so it replaces a color image at the same path, and it sits under a camera in a 3-D scene as an image does.

Arguments

Name Type Description Default
path str

The entity path, as for points.

required
depth Tensor | ndarray

Depths (H, W) as floats (cast to float32 on the device) or uint16, at most 8,192 pixels on a side.

required
scale float | None

Scene units per stored unit, above 0. None is 1 for floats and 0.001 for uint16, millimetres as metres.

None
cmap str | int

"viridis", "magma" or "rdbu", or 0, 1 or 2.

'viridis'
vmin float | None

Fixed lower end of the range, in scene units. None computes that end on the device.

None
vmax float | None

Fixed upper end of the range, as for vmin.

None
cloud bool | None

Also draw the back-projected point cloud. None draws it under a camera.

None
static bool

Copy the batch once at the call and retain it for every viewer.

False
rate float | None

Snapshots per second for this batch. None takes the rate of the scene.

None

Returns

Type Description
bool

True if a route took a snapshot, False if every route skipped it.

Raises

Type Description
TypeError

When path is not a string, static is not a bool, cloud is not a bool or None, or an argument has the wrong type.

ValueError

When path is not an entity path, depth is not floats or uint16 or not (H, W), is over 8,192 pixels on a side, scale is not above 0, the entity cannot hold an image, or the scene is at its limit of 1,024 entities or 2,048 batches.

segmentation

segmentation(path, class_ids, *, opacity=0.5, static=False, rate=None) -> bool

Log a segmentation image at entity path, replacing the image it held.

Each pixel is a class id, colored by the class table of classes. Ids travel as uint8 when the image is uint8 and as uint16 otherwise; an id outside 0 to 65,535 is clamped. The image sits under a camera in a 3-D scene.

Arguments

Name Type Description Default
path str

The entity path, as for points.

required
class_ids Tensor | ndarray

Integer class ids (H, W), at most 8,192 pixels on a side.

required
opacity float

From 0 to 1.

0.5
static bool

Copy the batch once at the call and retain it for every viewer.

False
rate float | None

Snapshots per second for this batch. None takes the rate of the scene.

None

Returns

Type Description
bool

True if a route took a snapshot, False if every route skipped it.

Raises

Type Description
TypeError

When path is not a string, static is not a bool, or an argument has the wrong type.

ValueError

When path is not an entity path, class_ids does not hold integers or is not (H, W), is over 8,192 pixels on a side, opacity is outside 0 to 1, the entity cannot hold an image, or the scene is at its limit of 1,024 entities or 2,048 batches.

camera

camera(
    path,
    *,
    width,
    height,
    focal=None,
    fov=None,
    principal=None,
    convention="rdf",
    plane_distance=None,
    static=False,
) -> bool

Log a pinhole camera at entity path.

The entity transform of path poses the camera (transform). The entity holds no primitive, the root holds no camera, and a camera is never under another. Its children live in its pixel space, where images and 2-D points, lines, arrows and boxes sit. The producer keeps the camera whether or not a viewer is attached, and the rate limit never drops it.

Arguments

Name Type Description Default
path str

The entity path of the camera, not the root.

required
width int

Image width in pixels, from 1 to 8,192.

required
height int

Image height in pixels, from 1 to 8,192.

required
focal float | tuple[float, float] | None

fx and fy in pixels, or one value for both. Give exactly one of focal and fov.

None
fov float | None

The vertical field of view in degrees, between 0 and 180, which sets fx = fy.

None
principal tuple[float, float] | None

(cx, cy) in pixels. None is the image centre.

None
convention str

"rdf" (x right, y down, z forward) or "rub" (x right, y up, looking along -z).

'rdf'
plane_distance float | None

How far in front of the camera its image plane is drawn, in scene units, above 0.

None
static bool

Retain the camera as part of the scene setup, which a later clear removes only when it is static too.

False

Returns

Type Description
bool

Always True.

Raises

Type Description
TypeError

When path is not a string, static is not a bool, width or height is not an int, or focal or principal has the wrong type.

ValueError

When path is not an entity path or is the root, the entity holds primitives or lies under a camera, width or height is outside 1 to 8,192, both or neither of focal and fov are given, fov, focal, principal or plane_distance is out of range, convention is unknown, or the scene is at its limit of 1,024 entities or 2,048 batches.

transform

transform(
    path,
    *,
    translation=None,
    rotation=None,
    scale=None,
    matrix=None,
    static=False,
) -> bool

Set the entity transform of path, mapping its space into the space of its parent.

The parts translation, rotation and scale are applied as T R S. Or give matrix, which excludes the parts. Each is numbers, an array or a tensor on any device; the transform of tensors is composed on their device and the transform of numbers on the host. A call with none of them resets the transform to the identity. The producer keeps the transform whether or not a viewer is attached, and the rate limit never drops it.

Arguments

Name Type Description Default
path str

The entity path, not the root.

required
translation Sequence[float] | Tensor | None

3 numbers in 3-D, 2 in 2-D and under a camera.

None
rotation Sequence[float] | Tensor | None

In 3-D a quaternion x y z w, normalized by the call. In 2-D and under a camera one angle in radians.

None
scale float | Sequence[float] | Tensor | None

1 number for all axes, or one per axis (3 in 3-D, 2 in 2-D and under a camera).

None
matrix Sequence | Tensor | None

A (4, 4) matrix in the usual row and column sense.

None
static bool

Retain the transform as part of the scene setup, which a later clear removes only when it is static too.

False

Returns

Type Description
bool

Always True.

Raises

Type Description
TypeError

When path is not a string, static is not a bool, or a part is not numbers, an array or a tensor.

ValueError

When path is not an entity path or is the root, matrix is given together with a part, a part or matrix has the wrong size or holds a type that is not a number, or the scene is at its limit of 1,024 entities.

classes

classes(table, *, static=True) -> bool

Replace the class table of the scene.

Points and boxes with class_ids and segmentation images are colored by it. An id without a color takes color id % 16 of the categorical palette. The producer keeps the table whether or not a viewer is attached, and the rate limit never drops it.

Arguments

Name Type Description Default
table dict

Maps a class id, an int from 0 to 65,535, to a label (at most 63 bytes), or to (label, color). A color is 3 or 4 integers from 0 to 255 or floats from 0 to 1. At most 4,096 entries.

required
static bool

Retain the table as part of the scene setup, which is the default.

True

Returns

Type Description
bool

Always True.

Raises

Type Description
TypeError

When table is not a dict, static is not a bool, or a class id is not an int or a value is neither a label nor (label, color).

ValueError

When the table has more than 4,096 classes, a class id is outside 0 to 65,535, a label is over 63 bytes, or a color is not 3 or 4 numbers in range.

clear

clear(path='', *, recursive=False, static=False) -> bool

Clear entity path: its primitives, camera and entity transform.

With recursive, the subtree of path is cleared too, and clear("", recursive=True) empties the live data of the scene. Static parts stay unless the clear is static too. A later log at the path brings a part back. The clear applies at once to what the producer keeps, and the rate limit never drops it.

Arguments

Name Type Description Default
path str

The entity path. The empty string is the root.

''
recursive bool

Also clear the subtree.

False
static bool

Also clear static parts.

False

Returns

Type Description
bool

Always True.

Raises

Type Description
TypeError

When path is not a string, or recursive or static is not a bool.

ValueError

When path is not an entity path.