Perception Messages

Output types for machine learning and computer vision pipelines — detections, segmentation masks, tracked objects, and landmarks.

from horus import Detection, Detection3D, BoundingBox2D, BoundingBox3D, SegmentationMask

Detection

2D object detection — flat constructor with class, confidence, and bounding box fields.

import horus

det = horus.Detection(
    class_name="person",
    confidence=0.95,
    x=100.0, y=50.0,
    width=100.0, height=250.0,
    class_id=0,
    instance_id=0,
)
FieldTypeDefaultDescription
class_namestr""Detected class name
confidencefloat0.0Detection confidence
x, yfloat0.0Bounding box top-left (px)
width, heightfloat0.0Bounding box size (px)
class_idint0Numeric class identifier
instance_idint0Instance identifier

Detection3D

3D object detection — flat constructor with center, dimensions, and yaw.

det3d = horus.Detection3D(
    class_name="car",
    confidence=0.87,
    cx=5.0, cy=2.0, cz=0.8,
    length=4.5, width=1.8, height=1.5,
    yaw=0.0,
)
FieldTypeDefaultDescription
class_namestr""Detected class name
confidencefloat0.0Detection confidence
cx, cy, czfloat0.0Bounding box center (m)
length, width, heightfloat0.0Bounding box dimensions (m)
yawfloat0.0Heading angle (rad)

BoundingBox2D

Axis-aligned 2D bounding box in pixel coordinates.

bbox = horus.BoundingBox2D(x=100.0, y=50.0, width=100.0, height=250.0)
FieldTypeDefaultDescription
x, yfloat0.0Top-left corner (px)
width, heightfloat0.0Box dimensions (px)

BoundingBox3D

3D bounding box in world coordinates.

bbox3d = horus.BoundingBox3D(
    cx=5.0, cy=2.0, cz=0.8,
    length=4.5, width=1.8, height=1.5,
    yaw=0.0,
)
FieldTypeDefaultDescription
cx, cy, czfloat0.0Box center (m)
length, width, heightfloat0.0Box dimensions (m)
yawfloat0.0Heading angle (rad)

SegmentationMask

Per-pixel class labels.

mask = horus.SegmentationMask(width=640, height=480, mask_type=0, num_classes=21)
FieldTypeDefaultDescription
width, heightint0Image dimensions (px)
mask_typeint0Segmentation mask type
num_classesint0Number of semantic classes

TrackedObject

Object with persistent tracking ID across frames.

tracked = horus.TrackedObject(
    track_id=42,
    x=100.0, y=50.0,
    width=100.0, height=250.0,
    class_id=0,
    confidence=0.9,
)
FieldTypeDefaultDescription
track_idint0Persistent tracking ID
x, yfloat0.0Bounding box top-left (px)
width, heightfloat0.0Bounding box size (px)
class_idint0Numeric class identifier
confidencefloat0.0Detection confidence

Landmark / Landmark3D

Visual landmarks for SLAM and localization.

lm = horus.Landmark(x=1.5, y=2.3, visibility=0.95, index=7)
lm3d = horus.Landmark3D(x=1.5, y=2.3, z=0.8, visibility=0.95, index=7)

Landmark

FieldTypeDefaultDescription
x, yfloat0.0Position (px or m)
visibilityfloat1.0Visibility score (0.0-1.0)
indexint0Landmark index

Landmark3D

FieldTypeDefaultDescription
x, y, zfloat0.03D position (m)
visibilityfloat1.0Visibility score (0.0-1.0)
indexint0Landmark index

Example: YOLO Detection Pipeline

import horus

def detect_tick(node):
    img = node.recv("camera.rgb")
    if img is None:
        return

    frame = img.to_numpy()  # Zero-copy
    results = model.predict(frame)

    for r in results:
        det = horus.Detection(
            class_name=r.class_name,
            confidence=float(r.confidence),
            x=r.x, y=r.y,
            width=r.w, height=r.h,
            class_id=r.class_id,
        )
        node.send("detections", det)

detector = horus.Node(
    name="yolo",
    subs=[horus.Image],
    pubs=[horus.Detection],
    tick=detect_tick,
    rate=30,
    compute=True,
    on_miss="skip",
)
horus.run(detector)

See Also