This is an Accident Detection System that uses machine learning to detect accidents in video footage. The system consists of a frontend built with Next.js, a backend built with Flask, and a Streamlit admin dashboard for managing and analyzing accident data.
-
Accident Detection:
- Detects accidents in uploaded video footage.
- Displays the severity score and accuracy in real-time.
-
Admin Dashboard:
- Upload and process video footage.
- View live video analysis with severity and accuracy overlays.
- View accident statistics and data in interactive charts.
-
Database Integration:
- Saves accident data (timestamp, location, severity, etc.) to a MySQL database.
-
Real-Time Notifications:
- Simulates real-time accident notifications for testing purposes.
- Frontend: Next.js
- Backend: Flask
- Admin Dashboard: Streamlit
- Machine Learning: TensorFlow/Keras (for accident detection)
- Database: MySQL
- Video Processing: OpenCV
Before running the application, ensure you have the following installed:
- Python 3.8+
- Node.js (for Next.js frontend)
- MySQL (for the database)
- Git (optional, for cloning the repository)
Clone the repository to your local machine:
git clone https://github.com/DLOADIN/RoadGuard-Rwanda
cd RoadGuard-Rwanda-
Navigate to the
backendfolder:cd backend -
Install Python dependencies:
pip install -r requirements.txt
-
Set up the MySQL database:
- Create a database named
accident_detection. - Update the database credentials in
backend/config.py.
- Create a database named
-
Run the Flask server:
python app.py
The backend will be running at
http://localhost:5000.
-
Navigate to the
frontendfolder:cd frontend -
Install Node.js dependencies:
npm install
-
Run the Next.js development server:
npm run dev
The frontend will be running at
http://localhost:3000.
-
Navigate to the
adminfolder:cd admin -
Install Python dependencies:
pip install -r requirements.txt
The admin dashboard will be running at
http://localhost:8501.
-
Ensure MySQL is running on your machine.
-
Create a database named
accident_detection. -
Run the following SQL query to create the
accidentstable:CREATE TABLE IF NOT EXISTS accidents ( ID INT AUTO_INCREMENT PRIMARY KEY, timestamp DATETIME NOT NULL, location VARCHAR(255) NOT NULL, severity_level ENUM('low', 'medium', 'high') NOT NULL, severity_score FLOAT NOT NULL, video_path VARCHAR(255) NOT NULL, accuracy FLOAT NOT NULL );
-
Update the database credentials in
backend/config.pyandadmin/admin.py.
-
Start the Flask backend:
cd backend python app.py -
Start the Next.js frontend:
cd frontend npm run dev -
Start the Streamlit admin dashboard:
cd admin streamlit run admin.py -
Open your browser and navigate to:
- Frontend:
http://localhost:3000 - Admin Dashboard:
http://localhost:8501
- Frontend:
/RoadGuard-Rwanda/
.project
├── app
│ ├── Dashboard
│ │ ├── Analytics
│ ├── components
│ │ ├── dashboard-charts.tsx
│ │ ├── dashboard-content.tsx
│ │ ├── header.tsx
│ │ ├── maindatatable.tsx
│ │ ├── notifications-table.tsx
│ │ ├── overview-cards.tsx
│ │ ├── overview-section.tsx
│ │ ├── search.tsx
│ │ ├── trend-charts.tsx
│ │ ├── user-nav.tsx
│ │ ├── video-highlights.tsx
│ │ ├── video-upload.tsx
│ ├── highlights
│ ├── styles
│ ├── ui
│ ├── upload
│ ├── layout.tsx
│ ├── page.tsx
│ ├── sidebar.tsx
│ ├── styles.css
├── utils
│ ├── favicon.ico
│ ├── global.ts
│ ├── layout.tsx
├── components/ui
│ ├── aurora-background.tsx
│ ├── backgrounditem.tsx
│ ├── benjostick.tsx
│ ├── fact.tsx
│ ├── footer.tsx
│ ├── globalcoverage.tsx
│ ├── hero.tsx
│ ├── navbar.tsx
│ ├── roadadvisory.tsx
├── node_modules
├── public
├── .gitignore
├── AUTHORS
├── CI components.json
├── declarations.d.ts
├── depcheck.ts
├── get-commits.sh
├── next.config.ts
├── package.json
├── package-lock.json
├── backend/ # Flask backend
│ ├── app.py # Flask application
│ ├── config.py # Database configuration
│ └── requirements.txt # Python dependencies
│
├── frontend/ # Next.js frontend
│ ├── pages/ # Next.js pages
│ ├── public/ # Static assets
│ ├── styles/ # CSS files
│ └── package.json # Node.js dependencies
│
├── admin/ # Streamlit admin dashboard
│ ├── camera.py # Video processing script
│ └── requirements.txt # Python dependencies
│
└── README.md # Project documentation
- Go to the Admin Dashboard (
http://localhost:8501). - Navigate to the Upload Footage page.
- Upload a video file (supported formats:
.mp4,.avi,.mov). - The video will be processed, and the analysis will be displayed in real-time.
- Go to the Admin Dashboard (
http://localhost:8501). - Navigate to the Data page to view accident records from the database.
- Go to the Admin Dashboard (
http://localhost:8501). - Navigate to the Statistics page to view interactive charts and graphs.
-
Database Connection Issues:
- Ensure MySQL is running and the database credentials are correct.
- Check the logs for any errors related to the database connection.
-
Video Processing Issues:
- Ensure OpenCV is installed correctly (
pip install opencv-python). - Check the logs for any errors related to video processing.
- Ensure OpenCV is installed correctly (
-
Streamlit App Not Running:
- Ensure all dependencies are installed (
pip install -r requirements.txt). - Check the logs for any errors related to Streamlit.
- Ensure all dependencies are installed (
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeatureName). - Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/YourFeatureName). - Open a pull request.
For any questions or issues, please contact:
- Your Name: [email protected]
- GitHub: DLOADIN
Enjoy using the RoadGuard Rwanda! 🚀