Flytrap: Real-Time Traffic Monitoring
Personal Project
2025

Vertical
Geography
Media Type(s)
Tags
Overview
Flytrap is a real-time object detection and tracking system for live video streams. Built on YOLO11 (You Only Look Once v11) and designed for SRT (Secure Reliable Transport) streams, it tracks vehicles, people, and bicycles and calculates movement metrics like direction and speed.
It started as a learning exercise to get hands-on with computer vision and object detection, and grew into a production system with monitoring and analytics.
References
- Website: https://five59.github.io/flytrap
- Repository: https://github.com/five59/flytrap
System pipeline
A four-stage workflow:
- Stream reception: SRT video streams come in through the multi-method fallback system.
- Frame processing: motion detection decides whether to run inference, skipping when nothing moves.
- Analytics engine: direction detection picks up left-to-right and right-to-left movement via midpoint crossing; speed estimation gives mph based on configurable road width.
- Data storage: metrics get logged to files and stored in InfluxDB for historical analysis and real-time monitoring through Grafana dashboards.
Features
Processing
- Motion-based inference: skips frames when nothing's moving, cutting compute load.
- Region of Interest (ROI) support: focus detection on specific areas (like road surfaces) for better accuracy and speed.
- Built-in object tracking across frames.
Analytics and monitoring
- Direction detection from spatial algorithms.
- Speed estimation in mph from configurable parameters.
- Time-series storage in InfluxDB.
- Grafana dashboards for live monitoring.
- Annotated screenshots for detected events.
Production features
- Multi-platform: Linux, Windows (WSL2), macOS.
- Hardware acceleration: auto-detects and uses CUDA, MPS, or CPU.
- Stream resilience: fallback between GStreamer, OpenCV, and FFmpeg.
- Headless operation for server environments.
- Docker config for deployment.
Technical architecture
The stack:
- YOLO11 object detection: 22% fewer parameters than YOLOv8, with higher mean Average Precision (mAP) on benchmark datasets. YOLO11 adds the C3k2 block, SPPF (Spatial Pyramid Pooling Fast), and C2PSA (Cross-Stage Partial Attention) for better feature extraction.
- SRT streaming protocol: Secure Reliable Transport is an open-source protocol for sub-second live video. SRT combines UDP's speed with TCP-style error correction, delivering reliable streams over unpredictable networks with end-to-end AES encryption.
- Multi-method stream reception: fallback chain (GStreamer → OpenCV → FFmpeg) so streams come through regardless of system configuration.
- Hardware acceleration: CUDA for NVIDIA GPUs, Apple Metal Performance Shaders (MPS) for Mac, and optimized CPU processing, with automatic hardware detection.
Supported Platforms
- Linux (native)
- Windows (via WSL2)
- macOS (with MPS acceleration support)
Hardware Requirements
- NVIDIA GPU with CUDA support (optional, for acceleration)
- Apple Silicon with Metal support (optional, for MPS acceleration)
- Multi-core CPU for CPU-only processing
Problem
Real-time object detection from live streams has several technical challenges that have to be solved together for a production system:
- Stream reliability and network resilience
- Computational efficiency vs. detection accuracy
- Cross-platform hardware acceleration
- Long-term stability and memory management
- Analytics and historical insight
- Deployment complexity
- Object movement analysis
To handle these, the system needed to:
- Process live SRT video streams with sub-second latency and network resilience.
- Hit real-time object detection (vehicles, people, bicycles) at 15+ fps.
- Auto-use CUDA, MPS, or CPU acceleration based on available hardware.
- Run for days or weeks without memory degradation or crashes.
- Calculate movement direction and estimate speed in mph.
- Store detection metrics in a queryable time-series database.
- Provide a real-time monitoring dashboard for system health and detection stats.
- Support headless deployment.
- Handle stream interruptions with automatic reconnection.
- Generate annotated screenshots for detected events.
- Minimize false positives through configurable region-of-interest filtering.
Learning outcomes
The project hit its learning goals and ended up as a production system.
Computer vision
- Hands-on with current object detection (YOLO11).
- Tracking algorithms and motion detection.
- Region-based processing and spatial analytics.
System architecture
- Fault-tolerant streaming pipelines with fallback.
- Hardware acceleration across CUDA, MPS, and CPU.
- Memory management and resource optimization for long-running processes.
DevOps and monitoring
- Time-series databases for metrics.
- Real-time Grafana dashboards.
- Headless server deployment and environment detection.
Video streaming
- SRT protocol implementation.
- Multi-codec support and stream processing optimization.
- Network resilience and error recovery.
Flytrap pulls those threads into a modular, fault-tolerant architecture with specialized subsystems:
- Resilient streaming infrastructure with fallback
- Motion-aware inference optimization
- Hardware-adaptive acceleration layer
- Aggressive memory management
- Time-series analytics stack
- Containerized deployment with auto-configuration
- Spatial analytics engine
What started as a learning exercise turned into a production-grade system covering ML operations, streaming infrastructure, and observability.