A real-time AI-powered public safety system that detects crowd overcrowding and fire hazards simultaneously using a live webcam feed — and triggers instant audio alerts.
CivicSafe monitors live video and raises alerts for two types of safety risks:
| Detection | Method | Alert Trigger |
|---|---|---|
| 👥 Crowd | YOLOv8 person detection | When crowd count ≥ threshold |
| 🔥 Fire | OpenCV HSV color masking | When fire-colored pixels > 4000 |
Both run in real time on a single webcam feed with a shared audio alert system (with 5-second cooldown to avoid repeated sounds).
Live Webcam Feed
│
├──► YOLOv8 (Person Detection)
│ └── Rolling 10-frame average → Crowd Alert
│
└──► OpenCV HSV Masking
└── Pixel threshold check → Fire Alert
│
🔔 Audio Alert (alert.wav) with cooldown
- Smooth counting: a 10-frame rolling buffer prevents flickering crowd counts from noisy detections
- Confidence filtering: only detections with ≥ 40% confidence are counted
- Modular code:
civic_safe.pyholds all logic;app_civic.pyis the clean entry point
- Python 3.x
- YOLOv8 (Ultralytics) — real-time object detection
- OpenCV — video capture and HSV fire detection
- NumPy — array operations
git clone https://github.com/Chandrika987/CivicSafe.git
cd CivicSafepip install -r requirements.txtpython app_civic.pyPress q to quit the live window.
In app_civic.py, adjust the crowd threshold:
crowd_detection(threshold=5) # Alert when 5+ people detectedCivicSafe/
├── civic_safe.py # Core detection logic (crowd + fire + alerts)
├── app_civic.py # Entry point
├── alert.wav # Alert sound file
├── yolov8n.pt # Pre-trained YOLOv8 nano model
├── requirements.txt
└── README.md
- Streamlit web dashboard for live monitoring
- Hugging Face model integration for smarter scene classification
- Multi-camera support
- Logging alerts to a database with timestamps
- Deploy as a portable desktop app
Chandrika Pala — B.Tech CSE, SRKR Engineering College
LinkedIn · GitHub