نظام ذكي لاكتشاف وتتبع الأغنام
Sheep Detection & Tracking System
A real-time sheep detection and tracking system using YOLOv8 and OpenCV.
The system assigns unique IDs to each sheep for accurate monitoring,
counting, and movement analysis in agricultural environments.
Project Overview
This project leverages deep learning and computer vision to automatically
detect, identify, and track sheep in live or recorded video streams.
Each detected sheep is assigned a persistent tracking ID, enabling
accurate herd monitoring, movement analysis, and behavioral studies.
The system is suitable for use with drones or fixed surveillance cameras
in smart farming applications.
Key Features
YOLOv8-Based Sheep Detection
- 🐑 High-accuracy sheep detection using a custom-trained YOLOv8 model (best.pt).
- ⚡ Real-time performance on live and recorded video feeds.
Persistent ID Tracking
- 🆔 Assigns a unique ID to each sheep using Ultralytics tracking.
- 🔁 Maintains identity across frames even in dense or overlapping groups.
Visual Annotation & Centroid Tracking
- 📦 Draws bounding boxes and class labels on each sheep.
- 🔵 Marks centroids for spatial and behavioral analysis.
Pixel Debugging & Zone Analysis
- 📏 Mouse callback tool to inspect pixel positions.
- 🚧 Useful for line crossing, zoning, and gate-based analytics.
Robust Multi-Sheep Handling
- 🐏 Designed to handle dense herds and partial occlusions.
- 🎯 Reliable re-identification for accurate counting and monitoring.
Technology Stack
- 🐍 Programming Language: Python 3.x
- 🧠 Object Detection: YOLOv8 (Ultralytics)
- 🎥 Computer Vision: OpenCV
- 🖥️ Visualization & Annotations: cvzone
- 📊 Data Processing: NumPy
- 🆔 Tracking Engine: Ultralytics Tracker
Use Cases
- 🐑 Livestock Management – Automated sheep counting and monitoring.
- 🚁 Drone Surveillance – Track herd movement from aerial footage.
- 📈 Agricultural Research – Analyze grazing patterns and group behavior.
- 🧾 Auditing & Compliance – Visual logs for livestock inspection.
- 🧑🌾 Smart Farming – Integrate with automated farm management systems.
Conclusion
This Sheep Detection & Tracking System provides a scalable and intelligent
solution for real-time livestock monitoring. By combining YOLOv8 detection
with persistent object tracking, the system reduces manual effort, improves
accuracy, and lays the foundation for advanced smart farming features such
as counting, geofencing, and cloud-based analytics.