نظام ذكي لاكتشاف وعدّ الكرنب
Cabbage Detection & Counting System
An AI-powered computer vision system that detects, tracks, and counts cabbages in real time using YOLO and
OpenCV. The system provides automatic object tracking, line-crossing–based counting, and annotated video output
for accurate agricultural monitoring.
Project Overview
This project implements a real-time cabbage detection and counting system leveraging YOLO deep learning models
for precision agriculture.
The system automatically detects cabbages, assigns each a unique tracking ID, and counts them as they cross a
defined virtual boundary line.
By combining object detection, tracking, and line-based counting logic, it provides accurate yield estimation
and monitoring for agricultural environments.
Key Features
Real-Time Cabbage Detection
- 🌿 Detects cabbages in real time using a custom-trained YOLO model.
- ⚡ High-speed and high-accuracy inference.
Object Tracking with Unique IDs
- 🆔 Assigns a persistent ID to each detected cabbage.
- 🔁 Prevents double counting across frames.
Line-Crossing Based Counting
- 📏 Counts cabbages only when crossing a virtual boundary line.
- 🧮 Accurate yield estimation logic.
Smart Visualization & Video Output
- 📦 Displays bounding boxes, center points, and tracking IDs.
- 📊 Shows live count overlay on video frames.
- 💾 Saves annotated output video for reporting.
Technology Stack
- 🐍 Programming Language: Python 3.x
- 🎥 Computer Vision: OpenCV
- 🧠 Object Detection Model: YOLO (Custom Trained – best.pt)
- 🧩 Libraries: ultralytics, cv2, cvzone, numpy
- 🆔 Tracking Method: YOLO built-in tracking (persist=True)
Use Cases
- 🌾 Agricultural Yield Estimation – Automatic crop counting.
- 🚜 Field Monitoring – Track crop density and growth.
- 🧮 Automated Harvest Counting – Estimate production quantities.
- 📷 Smart Farming Analytics – Integrate with dashboards and IoT systems.
- 🧠 AI Research – Extendable to multi-class crop detection.
Conclusion
The Smart Cabbage Detection and Counting System using YOLO and OpenCV is a powerful example of AI-driven
precision agriculture.
By combining real-time object detection, tracking, and line-based counting, the system automates crop
monitoring, reduces manual labor,
and delivers accurate data insights for smarter, scalable farm management.