ML & Segmentation
The original ML message types were removed in 0.1.10. For ML inference pipelines, use:
- Model I/O: Tensor and TensorPool for zero-copy tensor transport
- Detection results: Detection / Detection3D with bounding boxes
- Custom outputs: GenericMessage for cross-language data
- Segmentation:
SegmentationMask(below)
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:
| Field | Type | Description |
|---|---|---|
width | u32 | Mask width in pixels |
height | u32 | Mask height in pixels |
num_classes | u32 | Number of semantic classes |
mask_type | u32 | 0=semantic, 1=instance, 2=panoptic |
timestamp_ns | u64 | Nanoseconds since epoch |
seq | u64 | Sequence number |
frame_id | [u8; 32] | Camera frame identifier |
Methods:
| Method | Returns | Description |
|---|---|---|
semantic(w, h, num_classes) | SegmentationMask | Create semantic mask header |
instance(w, h) | SegmentationMask | Create instance mask header |
panoptic(w, h, num_classes) | SegmentationMask | Create panoptic mask header |
with_frame_id(id) | Self | Set frame ID |
with_timestamp(ts) | Self | Set timestamp |
frame_id() | &str | Get frame ID as string |
data_size() | usize | Mask data size in bytes (w * h) |
See Also
- TensorPool API — Zero-copy tensor memory management
- Vision Messages — Detection and bounding box types
- Perception Messages — Point cloud and depth sensing