ML & Segmentation

The original ML message types were removed in 0.1.10. For ML inference pipelines, use:

SegmentationMask

Output type for semantic, instance, and panoptic segmentation models. Fixed-size header (64 bytes) — the pixel data follows in shared memory.

use horus::prelude::*;

// Semantic segmentation (e.g., from DeepLab — 21 classes)
let mask = SegmentationMask::semantic(640, 480, 21)
    .with_frame_id("camera_front")
    .with_timestamp(1234567890);

// Instance segmentation (e.g., from Mask R-CNN)
let mask = SegmentationMask::instance(640, 480);

// Panoptic segmentation (e.g., from Panoptic-FPN — 80 classes)
let mask = SegmentationMask::panoptic(640, 480, 80);

// Send via topic
let topic: Topic<SegmentationMask> = Topic::new("segmentation")?;
topic.send(mask);

Fields:

FieldTypeDescription
widthu32Mask width in pixels
heightu32Mask height in pixels
num_classesu32Number of semantic classes
mask_typeu320=semantic, 1=instance, 2=panoptic
timestamp_nsu64Nanoseconds since epoch
sequ64Sequence number
frame_id[u8; 32]Camera frame identifier

Methods:

MethodReturnsDescription
semantic(w, h, num_classes)SegmentationMaskCreate semantic mask header
instance(w, h)SegmentationMaskCreate instance mask header
panoptic(w, h, num_classes)SegmentationMaskCreate panoptic mask header
with_frame_id(id)SelfSet frame ID
with_timestamp(ts)SelfSet timestamp
frame_id()&strGet frame ID as string
data_size()usizeMask data size in bytes (w * h)

See Also