Inspiration
Traffic monitoring is a common real-world computer vision application used in smart city systems, toll booths, and traffic analytics platforms. This project simulates a simplified version of such a system: given a video feed of highway traffic, it detects objects, assigns each a persistent tracking ID, and counts how many objects cross a virtual line — a core building block for vehicle counting and flow analysis systems.
What it does
A real-time object detection and tracking system built with YOLOv8 and OpenCV that detects vehicles in traffic footage, tracks them frame-to-frame with persistent IDs, and counts vehicles as they cross a defined line — all while overlaying live processing statistics on the output video.
How we built it
Component Technology Object Detection YOLOv8 (Ultralytics) Tracking Ultralytics built-in tracker (ByteTrack) Video Processing OpenCV Language Python 3
Detection & Tracking — Each frame is passed through YOLOv8 with persist=True, which maintains consistent object IDs across frames instead of treating every frame as an independent detection. Counting Logic — For every tracked object, the script stores its previous vertical center position. If an object's center moves from above the counting line to below it (or vice versa) between frames, the counter increments. Overlay & Output — Each processed frame is annotated with bounding boxes, the counting line, live vehicle count, and current FPS, then written to the output video file.
What's next for Vehicle Detection & Tracking System
Class-specific filtering (e.g., count only cars, trucks, and buses) Direction-aware counting (separate counts for inbound vs. outbound traffic) Speed estimation using frame-to-frame displacement and a calibrated pixel-to-distance ratio Multi-lane counting zones for highway segments Export counting data to CSV/JSON for further analysis or dashboarding
Log in or sign up for Devpost to join the conversation.