Computer Vision & Spatial Intelligence

Crowd Analytics & Zone Flow Engine

A high-performance, multi-threaded computer vision pipeline for real-time person detection, persistent ID tracking, zone-based spatial occupancy, and directional crowd flow analysis.

YOLOv8 ByteTrack OpenCV Multi-Threading Polygon Spatial Geometry Gradio Console Real-Time Telemetry

System Overview

Modern surveillance and crowd safety systems require instantaneous situational awareness without dropping frames. This project introduces an end-to-end multi-threaded analytics pipeline that consumes video feeds, performs hardware-accelerated YOLOv8 object detection, maps persistent object trajectories via ByteTrack, and evaluates custom user-defined geometric polygon zones in real time.

Crowd Analytics Zone Detection
Real-time polygon zone overlay with persistent ByteTrack IDs and trajectory tracking.

Key Innovations & Features

🎯

Real-Time Detection & Tracking

Leverages optimized YOLOv8 for per-frame bounding box extraction paired with ByteTrack's association matching for persistent track IDs even through heavy occlusion and intersecting crowd trajectories.

πŸ“

Zone-Based Spatial Analytics

Allows operators to define arbitrary polygon regions of interest (entrances, emergency corridors, transit platforms). Point-in-polygon algorithms compute live dwell time and crowd density per zone.

🧭

Directional Flow Estimation

Computes temporal displacement vectors for every tracked individual within each polygon to determine dominant group heading (North, South, East, West) and spot counter-flow bottlenecks.

🚨

Automated Alerting & Auditing

Emits structured JSON events and logs warnings to logs/run.log whenever zone occupancy or dwell durations breach configurable thresholds, enabling rapid emergency dispatch.

πŸ–₯️

Modern Gradio Web Console

Interactive dashboard providing live stream visualization, interactive polygon zone drafting, metric charts, threshold adjustments, and video export controls.

⚑

Multi-Threaded Decoupling

Dedicated threads for video decoding, GPU inference, tracking computation, and UI rendering connected through thread-safe queues ensure zero frame drops.

Pipeline Architecture

Data Processing Flow
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     Decoded Frame     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  RTSP / Video  β”‚ ────────────────────► β”‚  YOLOv8 Inference      β”‚
β”‚  Input Stream  β”‚                       β”‚  (GPU Batch Tensor)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                     β”‚ Detections
                                                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     Spatial Trajectoryβ”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Zone Polygon   β”‚ ◄──────────────────── β”‚  ByteTrack Associator  β”‚
β”‚ Point-in-Poly  β”‚                       β”‚  (Persistent Kalman ID)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β–Ό                             β–Ό                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Density & Flowβ”‚           β”‚ Automated Alertβ”‚          β”‚ Gradio Console β”‚
β”‚  Vector Engine β”‚           β”‚ JSON Log Queue β”‚          β”‚ Dashboard UI   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Demonstration Assets