Skip to content

rects.py

rerun.log.rects

class RectFormat

Bases: Enum

How to specify rectangles (axis-aligned bounding boxes).

XYWH = 'XYWH' class-attribute

[x,y,w,h], with x,y = left,top.

YXHW = 'YXHW' class-attribute

[y,x,h,w], with x,y = left,top.

XYXY = 'XYXY' class-attribute

[x0, y0, x1, y1], with x0,y0 = left,top and x1,y1 = right,bottom.

YXYX = 'YXYX' class-attribute

[y0, x0, y1, x1], with x0,y0 = left,top and x1,y1 = right,bottom.

XCYCWH = 'XCYCWH' class-attribute

[x_center, y_center, width, height].

XCYCW2H2 = 'XCYCW2H2' class-attribute

[x_center, y_center, width/2, height/2].

def log_rect(entity_path, rect, *, rect_format=RectFormat.XYWH, color=None, label=None, class_id=None, ext=None, timeless=False)

Log a 2D rectangle.

Parameters:

Name Type Description Default
entity_path str

Path to the rectangle in the space hierarchy.

required
rect Optional[npt.ArrayLike]

the rectangle in [x, y, w, h], or some format you pick with the rect_format argument.

required
rect_format RectFormat

how to interpret the rect argument

RectFormat.XYWH
color Optional[Sequence[int]]

Optional RGB or RGBA triplet in 0-255 sRGB.

None
label Optional[str]

Optional text to show inside the rectangle.

None
class_id Optional[int]

Optional class id for the rectangle. The class id provides color and label if not specified explicitly. See rerun.log_annotation_context

None
ext Optional[Dict[str, Any]]

Optional dictionary of extension components. See rerun.log_extension_components

None
timeless bool

If true, the rect will be timeless (default: False).

False

def log_rects(entity_path, rects, *, rect_format=RectFormat.XYWH, identifiers=None, colors=None, labels=None, class_ids=None, ext=None, timeless=False)

Log multiple 2D rectangles.

Logging again to the same entity_path will replace all the previous rectangles.

Colors should either be in 0-255 gamma space or in 0-1 linear space. Colors can be RGB or RGBA. You can supply no colors, one color, or one color per point in a Nx3 or Nx4 numpy array.

Supported dtypes for colors:
  • uint8: color components should be in 0-255 sRGB gamma space, except for alpha which should be in 0-255 linear space.
  • float32/float64: all color components should be in 0-1 linear space.

Parameters:

Name Type Description Default
entity_path str

Path to the rectangles in the space hierarchy.

required
rects Optional[npt.ArrayLike]

Nx4 numpy array, where each row is [x, y, w, h], or some format you pick with the rect_format argument.

required
rect_format RectFormat

how to interpret the rect argument

RectFormat.XYWH
identifiers Optional[Sequence[int]]

Unique numeric id that shows up when you hover or select the point.

None
colors Optional[Union[Color, Colors]]

Optional per-rectangle RGB or RGBA triplet in 0-255 sRGB.

None
labels Optional[Sequence[str]]

Optional per-rectangle text to show inside the rectangle.

None
class_ids OptionalClassIds

Optional class ids for the rectangles. The class id provides colors and labels if not specified explicitly. See rerun.log_annotation_context

None
ext Optional[Dict[str, Any]]

Optional dictionary of extension components. See rerun.log_extension_components

None
timeless bool

If true, the rects will be timeless (default: False).

False