Project Overview
This project is a real-time object detection, tracking, and directional counting system built using Ultralytics YOLO12 and OpenCV. Unlike typical people-only counters, this system is designed to detect multiple types of objects—such as people, boxes, and equipment—and count them as they move across a predefined virtual line in the video feed.
The system assigns unique tracking IDs to each object, classifies their movement direction as “IN” or “OUT”, and displays the real-time count dynamically. It works with both live camera input and video files, making it ideal for industrial automation, warehouse monitoring, logistics, and smart facility surveillance.
Features
-
Multi-Class Object Detection
Detects various object types such as people, boxes, machinery, and custom classes using a trained YOLO12 model. -
Unique Object ID Tracking
Tracks each object across frames using unique identifiers for consistent counting and analytics. -
Directional Movement Detection
Implements a virtual line to detect and differentiate object movement (IN vs. OUT) based on line crossing logic. -
Real-Time Counting Overlay
Displays live IN/OUT counts on the video frame with clear class labels and movement direction. -
Supports Video Files and Webcams
Works with real-time camera input or pre-recorded videos for flexible deployment. -
Pixel Coordinate Debugging Tool
Allows users to get pixel coordinates from the video using a mouse-click tool to assist in line placement and configuration. -
Modular and Extensible Codebase
Easily customizable to support new object classes, zones, filtering logic, or analytics outputs. -
Optimized for Real-Time Inference
Efficient frame-by-frame processing with YOLO12 and OpenCV for low-latency performance.
Tech Stack
-
Programming Language: Python
-
Libraries Used:
-
ultralytics(YOLO12) -
cv2(OpenCV) -
cvzone(for UI overlays)
-
-
Input Sources: Webcam or video file (e.g.,
vid.mp4) -
Environment: Python ≥ 3.8, CPU or GPU-based inference (YOLO12 supported)
Project Files
-
best.pt: Custom-trained YOLO12 model for detection -
vid.mp4: Sample input video -
test.py: Main script containing detection, tracking, and counting logic
Real-World Applications
-
-
Warehouse and Inventory Flow Monitoring
Track the movement of boxes, pallets, and other inventory across loading zones to automate stock entry and dispatch logs. -
Industrial Automation
Monitor the flow of machinery components, tools, or products within a factory floor to improve efficiency and reduce manual supervision. -
Logistics and Supply Chain Management
Count goods or transport trolleys entering and exiting a logistics hub or distribution center to streamline operations and prevent bottlenecks. -
Smart Building and Facility Management
Track people, carts, or equipment moving through corridors and access points for real-time occupancy insights or asset tracking. -
Surveillance and Security Systems
Detect unauthorized objects or people entering or exiting restricted areas, enhancing perimeter security in sensitive environments. -
Retail and Supermarket Automation
Monitor footfall and goods movement for insights into customer behavior and shelf stocking efficiency. -
Hospital and Healthcare Facilities
Track medical equipment or staff movement for better asset utilization, cleanliness routines, and patient traffic management. -
School and Campus Monitoring
Count students, staff, or delivery movements through campus gates to maintain safety and manage flow.
-
Conclusion
This project showcases an adaptable and efficient video analytics solution capable of tracking multiple object types in real time using the YOLO12 framework. By detecting and counting directional crossings of a virtual line, it supports a range of use cases from warehouse inventory flow and logistics control to general surveillance and smart infrastructure monitoring. The system’s modular design, real-time inference capability, and visual tracking feedback make it well-suited for both industrial and commercial environments. It can be extended further with object-specific filters, zone-based logic, or cloud-based analytics integration.

Reviews
There are no reviews yet.