FloodGuard is an intelligent monitoring system that uses computer vision to detect flooding events in real-time through video streams. When flooding is detected, the system automatically sends WhatsApp alerts to emergency responders, authorities, or community members, enabling rapid response to minimize damage and protect lives.
- Real-time Flood Detection: Processes video streams using a trained YOLOv8 model specifically tuned for flood detection
- WhatsApp Alert System: Automatically sends notifications with location information when flooding is detected
- Web-based Dashboard: Provides a live monitoring interface with real-time status updates
- REST API: Offers endpoints for system status, video feeds, and event monitoring
- Video Processing: Works with both live camera feeds and pre-recorded footage for testing
The system consists of two main components:
- Detection Engine: YOLO-based CV model processes video frames to identify flood events
- Notification System: REST API integration with WhatsApp to deliver alerts
- Python 3.8+
- OpenCV
- Flask
- Ultralytics YOLO
- Requests
- Pre-trained flood detection model (
best.pt) - WhatsApp notification endpoint (e.g., using Twilio API or custom webhook)
- Clone the repository
git clone https://github.com/yourusername/floodguard.git
cd floodguard- Install dependencies
pip install -r requirements.txt-
Download the pre-trained model (
best.pt) and place it in the project root directory. -
Configure the environment variables
# Create .env file for configuration
touch .envEdit the .env file with your API keys and endpoints:
# WhatsApp notification endpoint
NOTIFICATION_ENDPOINT=https://your-whatsapp-notification-endpoint.com/flood-alert
# Google Maps API key (for location services)
GOOGLE_MAPS_API_KEY=your_google_maps_api_key
# Flask secret key
FLASK_SECRET_KEY=your_flask_secret_key
Additionally, you can modify settings in flood_detection.py:
- Change the video source (
video_path) - Adjust detection sensitivity by modifying the confidence threshold (
conf=0.25) - Customize the alert message and location information
- Start the Flask server
python flood_detection.py-
Access the web interface
- Open your browser and navigate to
http://localhost:5000 - View the live video stream with flood detection overlay
- Monitor alert status in real-time
- Open your browser and navigate to
-
API Endpoints
/video_feed: Live video stream with detection overlay/flood_status: Current flood detection status in JSON format/flood_events: Server-sent events for real-time notifications
The system uses a webhook endpoint to trigger WhatsApp notifications. When flooding is detected:
- The system sends a GET request to the configured endpoint
- The request includes the location where flooding was detected
- The WhatsApp message includes:
- Alert notification
- Confidence level of detection
- Time of detection
- Location information
To set up your own WhatsApp notification service, you can use:
- Twilio API
- WhatsApp Business API
- Custom webhook that forwards messages to WhatsApp
The system can also be integrated with the EnvGuard environmental monitoring component to provide additional data points about air quality and other environmental factors in flood-affected areas.

- Multi-camera support for wider coverage
- Integration with weather forecasting APIs
- Mobile application for field responders
- Advanced analytics for flood prediction
- Community alert subscription system
- Integration with municipal emergency systems
- This system is designed as an assistive tool and should not replace official emergency systems
- Always verify flood detections through multiple sources before taking action
- Configure alert thresholds carefully to avoid false alarms
- Test the system regularly to ensure proper operation
MIT License
- YOLOv8 for object detection capabilities
- Google Maps API for location services
- Flask community for the web framework