Skip to content

Developing an AI drive application to help the mega gathering like Kumbh Mela Nashik

Notifications You must be signed in to change notification settings

NMOLE08/CrowdShield

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛡️ CrowdShield - AI-Driven Crowd Management System

Unified AI-Powered Crowd & Disaster Management for Nashik Kumbh Mela 2027

🎯 Overview

CrowdShield is a comprehensive AI-driven crowd management system designed specifically for mega gatherings like the Nashik Kumbh Mela 2027. The system combines the power of Flask backend with FastAPI features and Satellite Analysis to provide real-time crowd monitoring, intelligent alerts, and emergency response coordination.

🆕 New: Satellite Crowd Analysis Module

The satellite_analysis/ module provides advanced AI-powered analysis of satellite imagery for crowd density estimation and prediction. This module is specifically designed for large-scale events like Kumbh Mela and can be used independently or integrated with the main CrowdShield system.

Key Features:

  • 🛰️ Multi-Method Analysis: Edge density, texture analysis, blob detection, and hybrid approaches
  • 🤖 Machine Learning: Random Forest-based crowd count prediction
  • 📊 Data Management: JSON-based structured data storage
  • 🎯 Event Prediction: Predict crowd counts for recurring events
  • 📈 Visualization: Comprehensive analysis and prediction visualizations

🚀 Quick Start

Prerequisites

  • Python 3.8+
  • Git
  • Modern web browser

Installation

  1. Clone the repository

    git clone https://github.com/NMOLE08/CrowdShield.git
    cd CrowdShield
  2. Install dependencies

    pip3 install -r requirements.txt
    pip3 install -r satellite_analysis/requirements.txt
  3. Start the unified backend

    python3 main.py
  4. Access the system

Demo Mode

python3 scripts/run_demo.py

🤖 AI Models & Technologies

Computer Vision & AI

  • YOLOv8 (Ultralytics): Real-time person detection and crowd counting
  • OpenCV: Video processing and frame analysis
  • PyTorch: Deep learning framework for model inference
  • NumPy: Numerical computing for data processing
  • Pillow: Image processing and manipulation

Machine Learning & Analytics

  • Scikit-learn: Machine learning algorithms for predictive analytics
  • Pandas: Data manipulation and analysis
  • SciPy: Scientific computing and statistical analysis

Real-time Communication

  • Flask-SocketIO: WebSocket communication for real-time updates
  • Python-SocketIO: Real-time bidirectional communication
  • Paho MQTT: IoT device communication protocol

🌐 APIs & External Services

Mapping & Geospatial

  • OpenStreetMap (OSM) API: Free location services, geocoding, route optimization
  • OSRM: Open Source Routing Machine for directions
  • Nominatim: Free geocoding service
  • Mapbox: Interactive maps and heatmap visualization
  • Folium: Python mapping library for data visualization
  • Geopy: Geocoding and distance calculations

Communication & Notifications

  • Twilio: SMS and WhatsApp alert delivery
  • WebSocket: Real-time data streaming to frontend

Database & Storage

  • SQLite: Lightweight database for data persistence
  • SQLAlchemy: Database ORM and management
  • Flask-SQLAlchemy: Flask database integration

🏗️ System Architecture

Backend Components

┌─────────────────────────────────────────────────────────────┐
│                    CrowdShield Unified Backend              │
├─────────────────────────────────────────────────────────────┤
│  Flask Core (AI & Detection)    │  FastAPI Features         │
│  ├── YOLOv8 Detection          │  ├── WebSocket Server      │
│  ├── CCTV Management           │  ├── Twilio Integration    │
│  ├── Nashik Simulation         │  ├── Real-time Updates     │
│  ├── Route Optimization        │  └── Push Notifications    │
│  ├── Satellite Analysis        │                            │
│  └── Database Management       │                            │
└─────────────────────────────────────────────────────────────┘

Core Modules

  • crowd_detection.py: YOLOv8-based people detection
  • cctv_manager.py: Multi-stream video processing
  • enhanced_alert_system.py: Master branch's threshold engine
  • mapbox_heatmap_generator.py: Interactive map visualization
  • nashik_kumbh_simulator.py: Venue-specific simulation
  • route_optimizer.py: Crowd-aware navigation
  • database.py: Data persistence and management
  • satellite_crowd_analyzer.py: Satellite image analysis
  • enhanced_crowd_predictor.py: ML-based crowd prediction

📡 API Endpoints

Core Detection

  • POST /api/detect - Real-time crowd detection
  • GET /api/heatmap - Generate crowd density heatmap
  • GET /api/alerts - Get active alerts
  • POST /api/routes/optimize - Optimize routes based on crowd

Nashik Kumbh Mela

  • POST /api/nashik/simulate - Generate simulation scenarios
  • GET /api/nashik/status - Get venue status
  • GET /api/nashik/map-data - Get interactive map data
  • GET /api/nashik/realtime-map - Real-time map updates

Satellite Analysis

  • POST /api/satellite/analyze - Analyze satellite imagery
  • GET /api/satellite/predict - Get crowd predictions
  • GET /api/satellite/status - Satellite analysis status
  • GET /api/satellite/data - Historical analysis data

Alert System

  • GET /api/alerts - Get current active alerts
  • GET /api/alerts/status - Get alert system status
  • GET /api/alerts/history - Get alert history
  • POST /api/alerts/test - Test alert system with Twilio

🎪 Nashik Kumbh Mela Features

Venue Integration

  • 5 Strategic Gates: Ramkund, Godavari Ghat, Main Bridge, Temporary Bridge, Parking Area
  • Real Coordinates: Accurate Nashik location mapping
  • Capacity Management: Per-gate crowd limits and monitoring
  • Emergency Routes: Optimized evacuation paths

Simulation Scenarios

  • Normal Crowd Flow: Regular festival attendance
  • Peak Hour Rush: High-density periods
  • Emergency Situations: Stampede, fire, medical emergencies
  • Weather Conditions: Rain, heat impact on crowd behavior

🚨 Alert System

Threshold Engine

  • Density-Based Alerts: GREEN, YELLOW, RED, CRITICAL levels
  • Smart Cooldown: 5-minute cooldown between repeated alerts
  • Hourly Limits: Maximum 10 alerts per hour per location
  • Real-time Processing: Automatic alert generation from CCTV data

Alert Features

  • Multi-level Alerts: Based on crowd density and capacity
  • Location-Specific: Gate-specific alerting for Nashik Kumbh Mela
  • WebSocket Notifications: Real-time alert delivery
  • Twilio Integration: SMS/WhatsApp alert delivery
  • Alert History: Complete tracking with timestamps

🗺️ Map Integration

Mapbox Features

  • Interactive Heatmaps: Color-coded crowd density visualization
  • Real-time Updates: Live crowd data overlay
  • Gate Markers: All 5 Nashik Kumbh Mela gates with popups
  • Landmark Integration: Godavari River, Ramkund, Main Ghat
  • Alert Visualization: Real-time alert markers on map

OpenStreetMap Integration

  • Route Optimization: Crowd-aware navigation using OSRM
  • Geocoding: Free location services using Nominatim
  • Distance Matrix: Real-time distance calculations
  • Place Details: Venue information and details

📹 CCTV & Video Processing

Multi-Stream Processing

  • 5 CCTV Feeds: Real-time video streams from all gates
  • YOLOv8 Detection: Person detection with bounding boxes
  • Frame Generation: Simulated video frames with overlays
  • Performance Metrics: Real-time processing statistics

Video Features

  • Detection Overlays: Bounding boxes, labels, timestamps
  • Crowd Counting: Real-time person count per feed
  • Status Indicators: Visual status for each camera
  • Frame Caching: Optimized frame delivery

🎨 Frontend Dashboard

Modern UI Features

  • Glass-morphism Design: Modern glass-like interface
  • Responsive Layout: Works on all devices
  • Real-time Updates: Live data without page refresh
  • Interactive Maps: Mapbox integration with heatmaps
  • CCTV Thumbnails: Live camera feed previews

Dashboard Components

  • Live Statistics: Real-time crowd count and alerts
  • Interactive Map: Nashik Kumbh Mela venue visualization
  • Alert Panel: Active alerts with priority levels
  • CCTV Feeds: Clickable camera thumbnails
  • System Status: Health monitoring and status indicators

🔧 Configuration

Environment Variables

# Application
SECRET_KEY=your_secret_key
FLASK_DEBUG=True
PORT=5002

# OSM API (OpenStreetMap - Free, no API key required)
OSM_ENABLED=True

# Mapbox
MAPBOX_ACCESS_TOKEN=your_mapbox_access_token

# Twilio (Push Notifications)
TWILIO_ACCOUNT_SID=your_twilio_account_sid
TWILIO_AUTH_TOKEN=your_twilio_auth_token
TWILIO_PHONE_NUMBER=your_twilio_phone_number

# MQTT (optional)
MQTT_ENABLED=False
MQTT_BROKER=localhost
MQTT_PORT=1883

🧪 Testing

Test Scripts

  • test_enhanced_alerts.py: Enhanced alert system validation
  • test_cctv.py: CCTV functionality testing
  • test_api_endpoints.py: API endpoint verification
  • run_demo.py: Comprehensive system demo
  • test_setup.py: Satellite analysis environment testing

Test Coverage

  • Alert System: Threshold engine and cooldown logic
  • CCTV Integration: Multi-stream processing
  • Map Integration: Mapbox and Google Maps APIs
  • API Endpoints: All REST endpoints and WebSocket
  • Real-time Updates: Live data streaming
  • Satellite Analysis: ML model validation and testing

📁 Project Structure

CrowdShield/
├── src/
│   ├── api/           # Flask API layer
│   ├── core/          # Core AI & detection modules
│   └── config/        # Configuration management
├── frontend/          # Modern dashboard UI
├── backend/           # FastAPI features (integrated)
├── satellite_analysis/ # Satellite image analysis module
├── data/              # Generated data & models
├── scripts/           # Demo & utility scripts
├── tests/             # Test suites
└── docs/              # Documentation

🎯 Use Cases

For Authorities

  • Real-time Monitoring: Live crowd density tracking
  • Emergency Response: Instant alert system
  • Route Management: Optimized traffic flow
  • Resource Allocation: Data-driven decision making
  • Satellite Analysis: Large-scale crowd monitoring

For Event Organizers

  • Capacity Planning: Predictive crowd modeling
  • Safety Management: Proactive risk mitigation
  • Communication: Automated alert distribution
  • Analytics: Historical data analysis
  • Predictive Insights: ML-based crowd forecasting

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Ultralytics: YOLOv8 implementation
  • Mapbox: Interactive mapping
  • Twilio: Communication services
  • OpenCV: Computer vision library
  • Scikit-learn: Machine learning framework
  • Nashik Kumbh Mela Authorities: Venue information and requirements

📞 Support

For support and questions:


Built with ❤️ for Nashik Kumbh Mela 2027

About

Developing an AI drive application to help the mega gathering like Kumbh Mela Nashik

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •