This project uses YOLOv8 for real-time crowd detection in videos. It tracks individuals, groups them based on proximity, and detects crowds that meet a defined threshold.
- Detects individuals using YOLOv8.
- Tracks people across frames and assigns unique IDs.
- Identifies crowd formations based on predefined distance thresholds.
- Saves crowd count per frame in a CSV file.
git clone https://github.com/yourusername/crowd-detection.git
cd crowd-detectionpip install -r requirements.txtpython crowd_detection.py- CROWD_THRESHOLD: Minimum number of people required to be considered a crowd.
- DISTANCE_THRESHOLD: Maximum distance between people for them to be considered in the same group.
- FRAME_THRESHOLD: Number of frames a person remains tracked before being removed.
- Live Video Stream: Displays detected individuals and crowds.
- CSV Output: A file
crowd_detection_results.csvis generated containing:
| Frame Number | Crowd Count |
|---|---|
| 100 | 5 |
| 250 | 7 |
- Python 3.8+
- OpenCV
- YOLOv8 (Ultralytics)
- NumPy
- Pandas
- SciPy
This project is licensed under the MIT License.
- Ultralytics YOLOv8 for object detection.
- OpenCV for image processing.
- SciPy for spatial distance calculations.
opencv-python
opencv-python-headless
torch
torchvision
numpy
pandas
scipy
ultralytics