A production-ready AI system for real-time people counting and occupancy monitoring using state-of-the-art YOLO11 object detection. Perfect for hallways, entrances, retail spaces, and smart building management.
Key Capabilities:
- π― High-Speed Detection: Optimized YOLO11n model.
- β‘ Intel NCS2 Acceleration: Full support for OpenVINO FP16 acceleration.
- π₯ Real-Time Counting: Accurate "IN" and "OUT" tracking.
- π Raspberry Pi Native: Built for Pi 4/5 with
picamera2support. - π Ultra-Compact UI: Minimalist dashboard with "OUT" and "NOW" metrics.
- βοΈ Auto-Start: Systemd service for 24/7 autonomous operation.
We provide a single script to set up everything (Python, OpenCV, OpenVINO, Service).
# Clone the repository
git clone https://github.com/ayyoubbenmansour/Crowd_Counting_Detection_RaspberryPi.git
cd Crowd_Counting_Detection_RaspberryPi
# Run the auto-setup script
chmod +x setup_rpi.sh
./setup_rpi.shYou can run it manually or as a background service.
Manual Start (for testing):
python3 app.pyAccess the dashboard at http://<YOUR-PI-IP>:5000
Background Service (Auto-start on boot):
sudo systemctl start crowd_counting.serviceTo get maximum FPS on a Raspberry Pi 4, we recommend using the Intel Neural Compute Stick 2.
1. Export the Model:
yolo export model=yolo11n.pt format=openvino half=True2. Run with Acceleration:
python3 crowd_counting_rpi.py --model yolo11n_openvino_model/ --interactiveSee NCS2_GUIDE.md for full details.
The UI is designed to be unobtrusive overlaying the video feed.
| Metric | Description |
|---|---|
| OUT | Total number of people who have walked OUT of the zone. |
| NOW | Current Occupancy (people currently inside the zone). |
| Zone Status | Color-coded status (Green=OK, Orange=Warn, Red=Critical). |
Run in interactive mode to click-and-draw your counting zone.
python3 crowd_counting_rpi.py --interactiveRun without a GUI window, perfect for remote servers.
python3 crowd_counting_rpi.py --no-display --output debug_session.mp4Reduce resolution to gain FPS.
python3 crowd_counting_rpi.py --resolution 640 360Crowd_Counting_Detection_RaspberryPi/ βββ app.py # Flask Web Application (Video Streaming) βββ crowd_counting_rpi.py # Core AI Logic & Processing βββ setup_rpi.sh # One-click Installation Script βββ crowd_counting.service # Systemd Auto-start Service βββ DEPLOYMENT.md # Detailed Pi Deployment Guide βββ NCS2_GUIDE.md # Intel NCS2 Acceleration Guide βββ TRAINING_GUIDE.md # Guide to Fine-Tune Model βββ DATASETS.md # List of Public Datasets βββ logs.json # Local Log Storage (Generated at runtime) βββ templates/ # Web Interface Templates (layout, index, settings, logs) βββ yolo11n.pt # YOLO Model Weights βββ README.md # Documentation
---
## π€ Contributing
Contributions welcome!
- π Report bugs via Issues
- π‘ Suggest features
- π§ Submit pull requests
---
<div align="center">
**Β© 2025/2026 Real-time Crowd Counting**
</div>