warden-vision
Reusable computer vision building blocks for detection, tracking, and
annotation — detection/keypoint/classification data structures, geometry
and counting zones, two multi-object trackers, ~20 annotators, evaluation
metrics, dataset I/O, and video/image utilities — in the spirit of
Roboflow's Python supervision
library, reimplemented as a dependency-light, feature-gated Rust crate.
This is an independent project, not affiliated with or endorsed by Roboflow.
Why
Python supervision is the de facto toolkit for gluing together an object
detector's output, a tracker, and on-screen annotation. warden-vision
covers the same ground natively in Rust — no Python runtime, no PyTorch —
so it fits into Rust inference pipelines (e.g. using
ort, tract,
or candle to run the model
itself) without a foreign-language boundary between inference and
post-processing.
Features at a glance
- Core data model —
Detections/Detection(boxes, masks, confidence, class, tracker id),KeyPoints(pose/landmarks),Classifications(whole-image classification). - Detector-output parsing —
Detections::from_ultralytics_onnxandDetections::from_transformers_onnxparse the raw tensor layouts YOLOv8+ and DETR-family models produce, independent of which Rust inference runtime you used to run them. - Geometry —
Point,Rect, anchorPositions, polygon utilities,LineZone/PolygonZonecrossing/occupancy counters. - Tracking —
SortTracker(Kalman + IoU) andByteTracker(two-stage high/low-confidence matching), plusDetectionsSmootherfor jitter reduction andInferenceSlicerfor SAHI-style tiled inference. - Annotation — box, mask, polygon, label (bitmap font or, via
ab_glyph, real TTF/OTF), circle, dot, triangle, ellipse, round-box, box-corner, trace, heat map, halo, percentage bar, icon overlay, background dim, blur/pixelate redaction, and keypoint skeleton annotators — all working against a pure-Rustimage::RgbaImagebackend and (optionally) an OpenCVMatbackend, sharing one configuration type. - Metrics — Precision, Recall, F1, ConfusionMatrix, MeanAveragePrecision, MeanAverageRecall.
- Dataset I/O — COCO, YOLO, and Pascal VOC detection formats, plus an image-folder classification format.
- Video/image utilities —
FPSMonitor, letterbox/resize/crop/overlay,ImageSink, and (via OpenCVvideoio)VideoInfo/VideoSink/frame iteration.
Installation
[]
= { = "0.1", = ["annotate-image"] }
Feature flags
| Feature | Adds | Native deps required |
|---|---|---|
core (default) |
Detections, geometry, trackers, metrics — pure Rust, always on | none |
annotate-image |
Pure-Rust annotators drawing on image::RgbaImage, RichLabelAnnotator, image utilities |
none |
annotate-opencv |
The same annotators drawing on opencv::core::Mat, plus video I/O |
system OpenCV install |
datasets |
COCO/YOLO/Pascal VOC/classification dataset loaders and exporters | none |
core has no dependencies beyond ndarray/nalgebra/lapjv/thiserror
and builds anywhere Rust does. annotate-opencv needs a system OpenCV
install (imgproc + videoio modules) and a working bindgen/libclang
toolchain to build its native bindings.
Quick example
use ;
use ;
use SortTracker;
// Detections from your detector of choice for this frame (xyxy pixel
// boxes). See `Detections::from_ultralytics_onnx` /
// `from_transformers_onnx` if you're running a model directly.
let mut detections = new;
// Assign stable identities across frames.
let mut tracker = default;
tracker.update;
// Draw boxes + labels onto an RGBA frame.
let mut frame = new;
default.annotate.unwrap;
Runnable version: cargo run --example quickstart --features annotate-image
(see examples/quickstart.rs).
Module overview
| Module | Contents |
|---|---|
core |
Detection/Detections, KeyPoints, Classifications, InferenceSlicer, ONNX-tensor adapters |
geometry |
Point, Rect, Position, polygon utilities, LineZone/PolygonZone |
tracker |
SortTracker, ByteTracker, DetectionsSmoother |
annotators |
The Annotator trait and every drawing config, pure-Rust + OpenCV backends |
metrics |
Precision, Recall, F1Score, ConfusionMatrix, MeanAveragePrecision, MeanAverageRecall |
utils |
FPSMonitor, image resize/letterbox/crop/overlay, ImageSink |
dataset (feature datasets) |
COCO/YOLO/Pascal VOC/classification loaders and exporters |
video (feature annotate-opencv) |
VideoInfo, VideoSink, frame iteration |
Full API docs: cargo doc --open --features annotate-image,datasets.
Relationship to Python supervision
This crate mirrors supervision's API shape and covers its core
detection/tracking/annotation/metrics/dataset surface, but is not a
line-for-line port:
- Detector adapters parse raw ONNX output tensors
(
from_ultralytics_onnx,from_transformers_onnx) instead of binding toultralytics/transformersPython objects, which have no Rust equivalent — see thecore::adaptersmodule docs for the reasoning. - ByteTrack is a two-stage (high/low-confidence) implementation of the core idea, not a byte-for-byte port of the reference codebase.
- Not (yet) implemented:
RichLabelAnnotator's OpenCV backend (OpenCV has no built-in TTF rendering without FreeType), and a handful ofDetections.from_*adapters for detector libraries beyond Ultralytics/transformers.
Contributing
Issues and PRs welcome. Run cargo fmt, cargo clippy --all-targets --features annotate-image,datasets, and cargo test --features annotate-image,datasets before submitting — CI runs the same checks,
plus an annotate-opencv job that's allowed to fail (it needs a system
OpenCV install and isn't well-covered yet). If you touch that backend,
check its CI result and mention in your PR how you tested it.
License
MIT — see LICENSE.