CCTV Vehicle Count
& Traffic Flow Analytics
Computer vision traffic analytics platform built on YOLOv8 object detection and DeepSORT multi-object tracking. Processes existing RTSP CCTV feeds - no camera replacement needed. 3 vehicle classes, directional counting, 98.4% accuracy. Live hourly traffic volume reports.
CCTV cameras everywhere. Zero data insight.
Most CCTV deployments produce video footage that is only reviewed after an incident. The traffic data flowing through these cameras 24/7 - vehicle volume by hour, by vehicle class, by direction, congestion patterns - is entirely invisible to infrastructure planners, operations teams, and smart city administrators.
Manual Counting
Traffic surveys require deploying field operators at intersections for hours - expensive, infrequent, inaccurate.
No Real-Time Volume
Infrastructure planners work from quarterly surveys. Peak congestion patterns are unknown until they cause accidents.
Camera Investment Wasted
Millions spent on surveillance infrastructure that produces only reactive forensic value - not proactive operational intelligence.
YOLOv8 + DeepSORT on existing CCTV. No camera replacement.
YOLOv8 nano on every frame.
YOLOv8 nano model (optimized for edge inference speed) processes each RTSP video frame. Vehicle bounding boxes are detected with confidence threshold 0.40, classified into 3 vehicle types (car, truck/bus, motorcycle), and passed to the DeepSORT tracker. Processing runs on GPU-accelerated hardware for real-time throughput.
DeepSORT eliminates double-counts.
DeepSORT (Deep Simple Online and Realtime Tracking) assigns a persistent track ID to each detected vehicle across multiple frames. The virtual line counter only increments when a track ID crosses the counting line for the first time - preventing the same vehicle from being counted multiple times as it traverses multiple frames.
Hourly volume reports via REST API.
Counting results are written to a PostgreSQL time-series database with camera ID, vehicle type, direction, and timestamp. FastAPI serves aggregate reports: hourly volume, peak hour identification, vehicle class breakdown, and directional flow ratios. Dashboard provides live intersection status and historical trend charts.
Computer vision engineering stack.
Real production code from the traffic analytics system.
YOLOv8 nano model runs on CCTV RTSP stream frames. Each frame is processed for vehicle bounding boxes, classified by type (car, truck, motorcycle), and tracked across frames using DeepSORT for count accuracy.
1from ultralytics import YOLO2import cv23from deep_sort_realtime.deepsort_tracker import DeepSort45model = YOLO("yolov8n.pt")6tracker = DeepSort(max_age=30, n_init=3, nn_budget=100)78VEHICLE_CLASSES = {2: "car", 3: "motorcycle", 5: "bus", 7: "truck"}910def process_frame(frame: np.ndarray) -> list[VehicleDetection]:11 results = model(frame, conf=0.40, classes=list(VEHICLE_CLASSES.keys()))12 detections = []13 14 for r in results[0].boxes:15 cls_id = int(r.cls[0])16 vehicle_type = VEHICLE_CLASSES.get(cls_id, "unknown")17 bbox = r.xyxy[0].cpu().numpy() # [x1, y1, x2, y2]18 confidence = float(r.conf[0])19 detections.append([bbox, confidence, vehicle_type])20 21 tracked = tracker.update_tracks(detections, frame=frame)22 return [VehicleDetection(t.track_id, t.det_class, t.to_ltrb()) for t in tracked]Every frame, every millisecond.
RTSP Frame Capture
OpenCV captures frames from RTSP IP camera stream at configurable FPS (typically 5–10 FPS for vehicle counting accuracy). Frame buffer prevents processing lag during peak traffic.
YOLOv8 Detection Pass
YOLOv8n processes each frame: outputs bounding boxes [x1, y1, x2, y2], confidence scores, and class IDs for all detected vehicles in under 30ms on GPU (RTX 3060+).
Class Filtering
Only COCO classes 2 (car), 3 (motorcycle), 5 (bus), and 7 (truck) are retained. Pedestrians, cyclists, and other objects are filtered out before tracking.
DeepSORT Tracking Update
Detection bounding boxes passed to DeepSORT tracker. Tracker assigns persistent track IDs across frames using Kalman filter motion prediction and appearance embeddings. Track confirmed after n_init=3 consecutive detections.
Virtual Line Crossing Check
For each confirmed track, centroid Y-coordinate compared against virtual counting line Y. First crossing in either direction increments directional count, track ID added to counted_ids set.
Database Write & Alert
Per-minute count aggregates written to PostgreSQL traffic_counts table with camera_id, vehicle_type, direction, count, timestamp. Configurable congestion threshold dispatches Telegram alert.
Traffic intelligence, visualized.
Live Intersection Map
Mapbox GL map with camera markers colored by congestion level. Click any camera to open its live count feed and hourly volume chart.
Hourly Volume Charts
Recharts bar charts showing vehicle volume per hour, broken down by car/truck/motorcycle. 7-day historical comparison.
Peak Hour Identification
Automatic identification of AM and PM peak hours per camera. Used for signal timing optimization and enforcement scheduling.
Directional Flow Ratios
Northbound vs. southbound / eastbound vs. westbound flow ratios per camera. Identifies unbalanced lane usage and bottlenecks.
Vehicle Class Breakdown
Cars vs. heavy vehicles (trucks/buses) vs. motorcycles - percentage split by time of day. Useful for road surface stress modeling.
Congestion Alerts Table
Historical alert log: camera, timestamp, volume trigger, alert tier (Telegram vs. escalated). Alert acknowledgment workflow.
Traffic analytics schema.
Immutable time-series event log with per-minute granularity. Aggregation views for hourly and daily reports.
How 98.4% accuracy is achieved and maintained.
YOLOv8 Confidence Threshold
Detection confidence threshold set to 0.40 - balances recall (not missing vehicles) against precision (not counting shadows or false positives). Threshold tuned per camera based on lighting and camera angle.
DeepSORT Track Confirmation
New tracks only confirmed after 3 consecutive frames (n_init=3). This prevents single-frame false detections (dust, reflections) from incrementing counts.
Track ID Memory (counted_ids set)
Each track_id is stored in counted_ids after first crossing. Subsequent crossings by the same ID are ignored - eliminating double-counting of slow-moving vehicles.
Camera Angle Requirements
Minimum 30° camera angle to road plane recommended. Straight-down or near-parallel angles reduce detection accuracy. Optimal: 45°–60° from overhead, covering 15m–25m of road.
Who deploys this system.
Smart City Administration
Real-time traffic volume data for signal timing optimization, congestion pattern analysis, and infrastructure planning without new sensor hardware.
Highway & Toll Authorities
Vehicle count and classification (car vs. HGV) for toll pricing, axle load compliance, and lane occupancy statistics.
Industrial Campus Security
Entrance/exit vehicle counting for parking management, visitor logging, and after-hours intrusion detection at industrial sites.
Retail & Commercial Parks
Footfall-equivalent for vehicles: peak shopping hours, parking demand forecasting, delivery truck frequency analysis.
Construction Site Management
Contractor and material delivery vehicle count per day. Integration with gate pass systems for site access logging.
Urban Planning & Research
Origin-destination studies via multi-camera zone counting. Modal split analysis (cars vs. two-wheelers) for public transport planning.
What you need to deploy.
Camera Requirements
- RTSP-compatible IP camera (any brand)
- Minimum 720p resolution (1080p recommended)
- 30°–60° angle to road plane for accuracy
- IR illumination for night operation
- Stable RTSP stream (no heavy compression artifacts)
Server Requirements
- NVIDIA GPU with CUDA support (RTX 3060+ for real-time)
- 16GB RAM minimum for multi-camera setup
- Ubuntu 20.04+ with Docker
- Static IP or VPN access to RTSP streams
- 100GB storage per camera per month (event DB)
Optional Integrations
- Telegram Bot API for congestion alerts
- Email SMTP for scheduled hourly reports
- Mapbox GL for dashboard map display
- REST API webhook for third-party SCADA or ERP integration
Measured throughput and latency.
Questions about the system?
What CCTV hardware does this system work with?
How does the 98.4% accuracy figure hold up in real conditions?
Does this replace traffic control systems or supplement them?
What are the 3 vehicle classes tracked?
CCTV cameras already installed. Start extracting traffic data.
Arivu deploys the vehicle counting and traffic analytics system on existing RTSP camera infrastructure in 2–4 weeks. No new hardware procurement. No camera replacement. Contact the team in Bengaluru to scope your deployment.