Skip to content

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›ก๏ธ SentinelVision

A high-performance real-time person and object tracking system built in Rust, using:

  • OpenCV (video processing & rendering)
  • ONNX Runtime (YOLO inference)
  • SORT algorithm (multi-object tracking)

SentinelVision detects objects in video streams, assigns persistent tracking IDs, and renders real-time annotated output with RED bounding boxes.


๏ฟฝ Example Results

Here are some example detections from the system:

Raw Input Frame

Raw Input Frame

Sample Detection (Expected)

Sample Detection

Detection Only

Detection Overlay

Detection with Letterbox Preprocessing

Detection with Letterbox


๏ฟฝ๐Ÿš€ Features

  • ๐ŸŽฅ Video input support (file or webcam)
  • ๐Ÿง Real-time person/object detection using YOLO (ONNX)
  • ๐Ÿง  HOG fallback detector (OpenCV-based)
  • ๐ŸŽฏ Multi-object tracking using SORT
  • ๐Ÿ†” Persistent tracking IDs across frames
  • ๐Ÿ”ด RED bounding box visualization (strict requirement)
  • ๐Ÿ“Š Real-time labels (ID | class | confidence)
  • ๐Ÿ“ผ Optional video output recording
  • โšก Optimized for real-time performance (20โ€“30 FPS target)

๐Ÿ“ Status

๐Ÿšง Active development โ€” core pipeline (OpenCV + ONNX Runtime + YOLO + SORT tracking) is being actively implemented and stabilized


๐Ÿง  System Architecture

Video Input (Webcam / File)
โ†“
Frame Capture (OpenCV)
โ†“
Preprocessing (Resize / Normalize / Letterbox)
โ†“
ONNX Runtime Inference (YOLO)
โ†“
Detection Post-processing (Confidence Filtering + NMS)
โ†“
SORT Tracking (Kalman Filter + IoU + Hungarian Matching)
โ†“
Track Management (ID lifecycle handling)
โ†“
Rendering (RED bounding boxes + labels)
โ†“
Display / Optional Video Output

๐Ÿ› ๏ธ Tech Stack

Core

  • Rust ๐Ÿฆ€
  • OpenCV (Rust bindings)
  • ONNX Runtime (ORT)

Computer Vision

  • YOLOv8 / YOLOv5 (ONNX models)
  • HOG-based fallback detector (OpenCV)

Tracking

  • SORT algorithm:

    • Kalman Filter (motion prediction)
    • IoU matching (data association)
    • Hungarian assignment

๐Ÿ“ Project Structure

sentinelvision/
โ”‚
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.rs          # Pipeline orchestration
โ”‚   โ”œโ”€โ”€ config.rs        # Configuration & constants
โ”‚   โ”œโ”€โ”€ video.rs         # Video capture & frame handling
โ”‚   โ”œโ”€โ”€ detector.rs      # YOLO ONNX inference + HOG fallback
โ”‚   โ”œโ”€โ”€ tracker.rs       # Track lifecycle manager
โ”‚   โ”œโ”€โ”€ sort.rs          # SORT algorithm implementation
โ”‚   โ”œโ”€โ”€ bbox.rs          # Geometry + IoU utilities
โ”‚   โ”œโ”€โ”€ renderer.rs      # Visualization (RED bounding boxes)
โ”‚   โ”œโ”€โ”€ utils.rs         # Helper utilities
โ”‚
โ”œโ”€โ”€ models/
โ”‚   โ””โ”€โ”€ yolov8.onnx
โ”‚
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ input.mp4
โ”‚
โ”œโ”€โ”€ output/
โ”‚   โ””โ”€โ”€ output.mp4
โ”‚
โ”œโ”€โ”€ Cargo.toml
โ””โ”€โ”€ README.md

๐Ÿง  YOLO Model Setup (YOLOv8 โ†’ ONNX)

SentinelVision uses YOLO in ONNX format via ONNX Runtime.


๐Ÿ“ฅ Step 1 โ€” Install Python + Ultralytics

Create virtual environment:

python -m venv venv
source venv/bin/activate   # Linux / macOS
# OR
venv\Scripts\activate      # Windows

Install dependencies:

pip install ultralytics

๐Ÿ“ฆ Step 2 โ€” Download YOLOv8 Model

from ultralytics import YOLO

model = YOLO("yolov8n.pt")

This automatically downloads pretrained weights.

Recommended models:

  • yolov8n.pt โ†’ fastest (recommended)
  • yolov8s.pt โ†’ balanced
  • yolov8m.pt โ†’ more accurate

๐Ÿ” Step 3 โ€” Export to ONNX

from ultralytics import YOLO

model = YOLO("yolov8n.pt")

model.export(
    format="onnx",
    opset=12,
    simplify=True,
    dynamic=False,
    imgsz=640
)

๐Ÿ“ Step 4 โ€” Move Model into Project

mv yolov8n.onnx models/yolov8.onnx

Final structure:

models/
โ””โ”€โ”€ yolov8.onnx

โš™๏ธ Step 5 โ€” Verify Input Shape

Expected ONNX input:

[1, 3, 640, 640]

If different, update preprocessing in:

src/detector.rs

โ–ถ๏ธ Usage

Run with video file

cargo run --release -- data/input.mp4

Run with webcam

cargo run --release -- 0

๐Ÿง Detection Format

Each detection:

[x, y, width, height, confidence, class_id]

๐Ÿ†” Tracking Output Format

Each tracked object:

ID: <id> | <class> | <confidence>

๐Ÿ”ด Visualization Rules (STRICT)

All objects MUST be drawn using:

  • Color: RED (BGR = 0, 0, 255)
  • Thickness: 2โ€“3 px
  • Label placed above bounding box
  • Must include tracking ID

๐Ÿงช Debug Mode (Recommended)

Enable debug outputs:

  • Detection-only view
  • Tracking-only view
  • Frame-level logging

Optional debug artifacts:

  • Saved frames with overlays
  • Detection counts per frame
  • Track counts per frame

๐Ÿ“ˆ Performance Goals

  • 20โ€“30 FPS real-time processing
  • Minimal memory allocations
  • Lightweight SORT tracking
  • Frame skipping allowed if needed

โš ๏ธ Known Limitations

  • Occlusion may cause ID switches
  • CPU-only inference may reduce FPS
  • YOLO model quality affects accuracy
  • Lighting conditions impact detection reliability

๐Ÿ”ฎ Future Improvements

  • DeepSORT (appearance embeddings)
  • Multi-camera tracking
  • GPU acceleration (CUDA/OpenCL)
  • REST API for analytics
  • Event detection (loitering, intrusion)
  • Face recognition module

๐Ÿงฑ Design Philosophy

SentinelVision is built with:

  • Minimal dependencies
  • Explicit control over each pipeline stage
  • Performance-first architecture
  • No unnecessary abstractions
  • Production-oriented Rust design

๐Ÿ“ฆ Dependency Policy

  • Prefer std first
  • Avoid unnecessary crates
  • No Python runtime dependency
  • No heavy ML frameworks beyond ONNX Runtime
  • Keep architecture minimal and explicit

๐Ÿค Contributing

Rules:

  • Do NOT change architecture without discussion
  • Do NOT add unnecessary dependencies
  • Keep modules minimal and focused
  • Maintain Rust idioms and performance focus
  • Ensure changes do not break pipeline flow

About

SentinelVision is a real-time object detection and multi-object tracking system built in Rust using OpenCV and ONNX Runtime. It performs live person tracking with persistent IDs and visual bounding boxes for video analytics applications.

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages