A modular detection system designed for real-time fire and smoke detection with a scalable architecture that can be extended to other detection tasks such as PPE detection, human detection, and more.
- Overview
- Features
- Tech Stack
- System Architecture
- Installation
- Usage
- API Documentation
- Database Schema
- Notification System
- Video Sources
- Environment Configuration
- License
This project is a comprehensive solution for a fire/smoke detection system that integrates with pretrained AI models to provide real-time detection alerts. The system is designed with modularity in mind, allowing for easy extension to other detection tasks in the future.
The dashboard provides a user-friendly interface for monitoring multiple camera feeds, configuring detection parameters, managing camera regions and sub-regions, and viewing detection logs and analytics.
- Real-time monitoring of multiple camera feeds
- Intuitive navigation between different system modules
- Responsive design for desktop and mobile devices
- Add, edit, and delete camera configurations
- Configure RTSP URLs for video streams
- Organize cameras by regions and sub-regions
- Toggle camera status (Active/Inactive)
- Assign access levels to control camera visibility
- Create and manage regions and sub-regions
- Hierarchical organization of physical spaces
- Associate cameras with specific areas for better organization
- Simplified navigation through camera feeds by location
- Real-time fire and smoke detection alerts
- Configurable alert thresholds
- Visual and optional audio notifications
- Historical detection data visualization
- Exportable reports in multiple formats
- Customizable date range filtering
- Role-based access control
- User activity logging
- Secure authentication system
- Adjustable detection sensitivity
- Notification preferences
- System performance settings
- React: Core framework for building the user interface
- React Router: For navigation and routing
- React Bootstrap: UI component library
- React Icons: For iconography
- Flask: Python web framework for the API
- MySQL Connector: For database interactions
- JWT: For secure authentication
- OpenCV: For video feed processing and frame extraction
- yt-dlp: For YouTube video stream extraction
- MySQL: For storing user data, camera configurations, regions, and system settings
- Ultralytics YOLO: For object detection and fire/smoke identification
- OpenCV: For image processing and computer vision tasks
- Custom pretrained models: For fire and smoke detection
The system follows a modular architecture with the following components:
- Frontend Module: React-based dashboard for user interaction
- Backend Module: Flask API with Blueprint-based organization
- Detection Module: Handles integration with AI models
- Database Module: Manages data storage and retrieval
- Authentication Module: Handles user authentication and authorization
- Notification Module: Manages alerts and notifications to administrators
This modular approach allows for:
- Independent development and testing of components
- Easy replacement or upgrade of individual modules
- Scalability to handle additional detection tasks or features
- Node.js (v14 or higher)
- npm (v6 or higher)
- Python (v3.8 or higher)
- MySQL (v8.0 or higher)
- Clone the repository:
git clone https://github.com/your-organization/fire-smoke-detection.git
cd fire-smoke-detection
- Set up Python virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r backend/requirements.txt
- Configure environment variables:
# Edit backend/.env file with your database credentials
MYSQL_HOST=localhost
MYSQL_USER=your_mysql_username
MYSQL_PASSWORD=your_mysql_password
MYSQL_DATABASE=asadel_db
JWT_SECRET_KEY=your_secret_key
EMAIL_APP_PASSWORD=your_email_app_password
- Initialize the database:
python backend/init_db.py
- Start the backend server:
python backend/app.py
- Install dependencies:
npm install
- Start the development server:
npm start
Navigate to http://localhost:3000
in your web browser to access the dashboard.
- Go to the Camera Management section
- Click "Add Camera"
- Enter the camera details including RTSP URL
- Select a region and sub-region from the dropdown menus
- Set the access level and description
- Save the configuration
- Go to the Area Management section
- Use the interface to add new regions
- For each region, add relevant sub-regions
- Existing regions and sub-regions can be edited or deleted
- Go to the Settings section
- Adjust detection sensitivity
- Configure notification preferences
- Save changes
- Go to the Reports & Analytics section
- Select the desired date range
- View detection events and export reports as needed
The system exposes the following API endpoints:
POST /api/login
: User login
GET /api/users
: List all users (paginated)GET /api/users/:id
: Get user detailsPOST /api/users
: Create a new userPUT /api/users/:id
: Update user detailsDELETE /api/users/:id
: Delete a user
GET /api/cameras
: List all cameras (paginated)GET /api/cameras/:id
: Get camera detailsPOST /api/cameras
: Add a new cameraPUT /api/cameras/:id
: Update camera detailsPUT /api/cameras/:id/status
: Update camera statusDELETE /api/cameras/:id
: Delete a camera
GET /api/regions
: Get all regions with their sub-regionsGET /api/regions/:id
: Get details of a specific regionGET /api/regions-list
: Get a simplified list of regionsPOST /api/regions
: Create a new regionPUT /api/regions/:id
: Update a regionDELETE /api/regions/:id
: Delete a regionPOST /api/sub-regions
: Add a sub-region to a regionPUT /api/sub-regions/:id
: Update a sub-regionDELETE /api/sub-regions/:id
: Delete a sub-region
The database consists of the following main tables:
id
: Primary keyusername
: User's login namepassword_hash
: Hashed passwordrole
: User role (admin, operator, viewer)created_at
: Account creation timestampemail
: Email address for notifications
id
: Primary keyname
: Camera namertsp_url
: RTSP URL for the video streamregion
: Foreign key to regions tablesub_region
: Foreign key to sub_regions tabledescription
: Camera descriptionaccess_level
: Access level required to view this camerastatus
: Camera status (Active, Inactive)created_at
: Creation timestamp
id
: Primary keyname
: Region namedescription
: Optional descriptioncreated_at
: Creation timestamp
id
: Primary keyname
: Sub-region nameregion_id
: Foreign key to regions tabledescription
: Optional descriptioncreated_at
: Creation timestamp
id
: Primary keycamera_id
: Foreign key to cameras tableregion_id
: Foreign key to regions tablesub_region_id
: Foreign key to sub_regions tabledetection_type
: Type of detection (fire, smoke)confidence
: Detection confidence leveltimestamp
: When the detection occurredimage_path
: Path to saved screenshot of detection
The system is designed to be easily extended to other detection tasks:
- Add new detection models to the frontend
- Create new database tables and API endpoints for new features
- Implement new UI components for additional functionality
The system includes a robust email notification system to alert administrators when fire or smoke is detected:
- Automatic email alerts to all admin users when fire/smoke is detected
- Detailed information including camera name, region, sub-region, and timestamp
- Intelligent deduplication to prevent alert fatigue
- Configurable thresholds for notification triggering
- Gmail account for sending alert emails
- App password for secure authentication (2FA required)
- Admin user emails stored in database
Email notification system is configured through the .env
file with the following parameters:
EMAIL_APP_PASSWORD=your_app_password
The system uses a dedicated Gmail account ([email protected]
) to send notifications.
The system supports multiple video sources for detection:
- RTSP Streams: Connect to IP cameras or security DVR/NVR systems
- YouTube Links: Process live streams or uploaded videos from YouTube
- Local Files: Analyze video files stored on the server
- CCTV Cameras: Connect to existing CCTV infrastructure
YouTube links can be directly entered as camera sources. The system will:
- Extract the video stream using yt-dlp
- Process frames through the detection model
- Display the results on the dashboard
- RTSP:
rtsp://username:[email protected]:554/stream1
- YouTube:
https://www.youtube.com/watch?v=VIDEO_ID
- Local File:
/path/to/local/video.mp4
The application uses environment variables for configuration. Create a .env
file in the project root:
# Database configuration
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=asadel_db
# JWT secret key for authentication
JWT_SECRET_KEY=your-secret-key
# Email credentials
EMAIL_APP_PASSWORD=your_app_password
# Server configuration
PORT=5000
DEBUG=True
This project is licensed under the MIT License