Project Description:
This project implements a real-time tracking and zone monitoring system using a custom-trained YOLO model. The system enables users to define multiple polygonal zones of interest within a video frame (such as regions on factory floors, parking lots, or poultry environments) and tracks objects in these zones.
Core Objectives:
-
Allow users to define custom polygonal zones via mouse clicks.
-
Track moving objects inside a video using YOLO.
-
Detect whether tracked objects are present within any of the user-defined zones.
-
Count and display:
-
Total zones
-
Occupied zones (zones with objects)
-
Free zones (zones without any object)
-
Key Features:
✅ Zone Drawing Mode:
-
Interactive polygon zone drawing via mouse clicks (4 points per polygon).
-
Ability to undo last polygon, clear current drawing, or reset all zones.
-
Polygons are persistently stored in a
polygons.jsonfile for reuse.
✅ Tracking Mode:
-
Utilizes
YOLOfrom theultralyticslibrary for real-time detection and tracking. -
Object centers (
cx,cy) are tested to check if they lie inside any polygon. -
Uses
cv2.pointPolygonTest()to determine object-zone intersection. -
Highlights occupied polygons in red and marks detected object centers with a colored dot.
✅ Zone Count Analytics:
-
Continuously displays the number of:
-
Total zones
-
Free zones
-
Occupied zones
-
Technologies Used:
-
Computer Vision: OpenCV, Ultralytics YOLO
-
UI & Visualization: cvzone
-
Data Management: JSON (for persistent polygon storage)
-
Deep Learning: YOLO for detection and tracking
-
Language: Python
Custom Enhancements:
-
Allow zones with variable number of points (not just 4).
-
Add zone names/labels for identification.
-
Log time spent by each object in a zone.
-
Export zone occupation statistics to CSV or cloud database.
-
Support live webcam streams or IP cameras.
Use Cases:
-
Industrial Monitoring: Track object movement or machine operation within defined safety zones.
-
Livestock Management: Monitor animals inside designated pens or feeding areas.
-
Retail Analytics: Detect customer presence in store zones to optimize layout and staffing.
-
Surveillance Systems: Monitor restricted or high-priority zones for intrusion detection.
-
Parking Lot Management: Count occupied and free parking zones.
-
Smart Office Spaces: Detect occupancy in meeting rooms or collaborative areas.
Conclusion:
This Python-based project delivers a complete and interactive solution for zone-based object tracking using the YOLO model. With custom polygon zone drawing, automated zone occupancy detection, and real-time video annotation, it serves as an excellent tool for monitoring environments such as warehouses, public venues, or livestock pens. The code structure is modular, extendable, and ready for deployment in real-world applications where spatial awareness and object presence tracking are critical.


Reviews
There are no reviews yet.