https://github.com/arshtiwari2004/signal-x
Signal-X is an AI-powered traffic management system using advanced computer vision, edge computing, and geospatial intelligence. With real-time sensor fusion, machine learning algorithms, and adaptive signal control, it enables dynamic congestion management and emergency vehicle prioritization.
https://github.com/arshtiwari2004/signal-x
arduino deepsort expo flask opencv pygame python react-native tensorflow yolov8
Last synced: about 1 year ago
JSON representation
Signal-X is an AI-powered traffic management system using advanced computer vision, edge computing, and geospatial intelligence. With real-time sensor fusion, machine learning algorithms, and adaptive signal control, it enables dynamic congestion management and emergency vehicle prioritization.
- Host: GitHub
- URL: https://github.com/arshtiwari2004/signal-x
- Owner: ArshTiwari2004
- Created: 2025-04-04T13:08:32.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-06T00:16:20.000Z (about 1 year ago)
- Last Synced: 2025-04-10T22:48:33.823Z (about 1 year ago)
- Topics: arduino, deepsort, expo, flask, opencv, pygame, python, react-native, tensorflow, yolov8
- Language: JavaScript
- Homepage: https://signal-x-zkh5.vercel.app
- Size: 48.7 MB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Breaking the Red Tape of Congestion and Inefficiency
|
[](https://opensource.org/licenses/MIT)
[](https://www.python.org/downloads/)
[](https://reactjs.org/)
[](https://flask.palletsprojects.com/)
## ๐ Overview
Signal-X is an AI-driven smart traffic management system that uses YOLO-based vehicle detection, Arduino-controlled signals, and MapMyIndiaโs geospatial analytics to optimize traffic flow in real-time. It prioritizes emergency vehicles, prevents congestion, and enhances road safety through dynamic signal adjustments using live video feeds. Scalable and future-ready, Signal-X is adaptable for cities of all sizes, making urban commuting smarter and more efficient.
## ๐ง Problem Statement
### โ The Urban Gridlock Crisis
With rapid urbanization and an ever-increasing number of vehicles, cities are choking under **intense traffic congestion**. What should be smooth commutes turn into daily nightmares, leading to:
- โฑ๏ธ **Wasted Time** stuck in endless queues
- โฝ **Higher Fuel Consumption** and rising transportation costs
- ๐ซ๏ธ **Increased Pollution** and carbon emissions
- ๐จ **Delayed Emergency Responses** for ambulances, fire trucks, and police
- ๐ **Driver Frustration** and rising road rage incidents
---
### ๐ฆ The Flaws of Conventional Traffic Lights
Traditional traffic systems follow **fixed-timer logic**, blindly rotating signals **without considering real-time traffic flow**. This outdated mechanism leads to:
- ๐ข **Green lights on empty roads**, wasting valuable intersection time
- ๐ด **Vehicle pile-ups in busy lanes**, creating bottlenecks
- ๐ **Emergency vehicles stuck**, unable to move swiftly through intersections
- ๐งโโ๏ธ **Manual control dependency**, requiring more manpower
- ๐ง **No AI, No Adaptability**, making systems unresponsive and inefficient
---
### ๐ง The Need for a Smarter Solution
To truly **revolutionize urban mobility**, we need a system that is:
- โ
**AI-powered** and capable of dynamic decision-making
- ๐ **IoT-integrated** for real-time traffic sensing
- ๐บ๏ธ **Geospatially aware** for adaptive routing
- โ๏ธ **Automated & Scalable**, reducing human dependency
> Itโs time to move beyond timers and take the **smart route** to traffic management.
---
## ๐ก Our Solution โ Signal-X
**Signal-X** is an AI-driven Smart Traffic Management System that transforms urban mobility using the power of **computer vision**, **IoT**, and **geospatial intelligence**. Designed to be **scalable**, **real-time**, and **intelligent**, Signal-X optimizes traffic flow, reduces congestion, and ensures faster emergency response through dynamic signal control.
---
### ๐ Key Features
- ๐ง **AI-Powered Traffic Analysis**
YOLOv8-based object detection continuously monitors vehicle flow across all junction lanes.
- โฑ๏ธ **Dynamic Signal Adjustment**
Adaptive signal control based on real-time congestion and traffic density patterns.
- ๐ **IoT Integration**
Raspberry Pi/Arduino-based controllers ensure seamless traffic light control and emergency detection.
- ๐บ๏ธ **Geospatial Intelligence**
Integration with MapMyIndia's API offers live congestion updates and smart rerouting.
- ๐ **Emergency Vehicle Prioritization**
Automatically detects emergency vehicles (ambulance, fire brigade, police) and gives them green-light priority.
- ๐ฎ **Congestion Prediction**
AI models analyze historical + real-time data to predict and prevent traffic bottlenecks.
---
## ๐งฉ How Signal-X Works โ Workflow
Signal-X operates through a seamless, AI-driven pipeline that integrates video processing, intelligent decision-making, and hardware-level execution.
---
### โ๏ธ Step-by-Step Workflow
1. ๐ฅ **Live Data Collection**
- RTSP streams from **CCTV cameras and drones** provide real-time traffic video feeds.
2. ๐บ๏ธ **Traffic API Integration**
- Feeds are passed to **MapMyIndia Traffic API** for real-time congestion data enrichment.
3. ๐ง **Vehicle Detection using YOLOv8**
- Vehicles are identified and classified into 5 categories:
๐ Ambulance, ๐งฌ Organ Transport, ๐ Fire Brigade, ๐ Police, ๐ Disaster Units
4. ๐ **Real-Time Multiprocessing**
- Uses Pythonโs **multiprocessing** to analyze **all four lanes** at a junction simultaneously for accurate density analysis.
5. ๐งฎ **Smart Signal Optimization**
- A custom AI model determines the optimal green-light timing using:
- ๐ **Vehicle Density**
- ๐ **Historical Traffic Patterns** (via Reinforcement Learning)
- ๐ก **Live API Congestion Data**
6. ๐ **IoT-Based Hardware Integration**
- Arduino module integrated into the junction system.
- If an emergency vehicle is detected, **immediate green signal** is activated and maintained until it passes.
7. ๐ฅ๏ธ **Real-Time Dashboard (React)**
- Officers monitor and visualize traffic flow and system decisions via a **React-based dashboard** in real-time.
---
### ๐ฏ Why Signal-X?
> Unlike traditional fixed-timer systems, Signal-X uses **real-time intelligence and automation** to enhance traffic efficiency, reduce delays, and save lives.
โ
Smart
โ
Scalable
โ
Emergency-Ready
โ
Real-Time
โ
AI-Optimized
## ๐ง Technical Architecture
### Components Overview
1. **Data Collection Layer**
- CCTV cameras & drones capture live video feeds
- Microphone sensors detect emergency vehicle sirens
- IoT devices (Raspberry Pi & Arduino) process sensor inputs
2. **AI Processing Layer**
- YOLOv8 for vehicle detection and classification
- DeepSORT for vehicle tracking
- OpenCV for image processing
- Flask for API management
3. **Backend Processing**
- MongoDB for data storage
- WebSocket for real-time communication
- Traffic analysis algorithms
4. **Frontend Dashboard**
- React-based responsive interface
- Real-time traffic analytics visualization
- MapMyIndia integration for geospatial display
5. **Signal Control System**
- Priority-based signal switching for emergency vehicles
- Adaptive traffic light control based on congestion analysis
## ๐ป Technology Stack
## ๐งฐ Tech Stack โ What Powers Signal-X ๐ฆ
Signal-X is built using a powerful blend of **AI, hardware, geospatial analytics, real-time systems, and scalable web technologies**. Here's everything under the hood:
---
### ๐ Frontend โ **React Dashboard**
| Tech | Purpose |
|------|---------|
| โ๏ธ React.js | Dynamic, component-based UI |
| ๐บ๏ธ MapMyIndia SDK | Interactive maps & live traffic visualization |
| ๐ Tailwind CSS | Modern utility-first styling |
| ๐ก WebSocket | Real-time UI updates & traffic stats |
| ๐ Axios | API requests and data fetching |
| ๐ฑ React Native (Expo) | Mobile traffic monitor app (optional extension) |
---
### ๐ง AI & Computer Vision โ **Smart Traffic Brain**
| Tech | Purpose |
|------|---------|
| ๐ง YOLOv8 | High-speed vehicle detection & classification |
| ๐ฅ OpenCV (cv2) | Image & video stream processing |
| ๐ NumPy, SciPy | Traffic data analytics |
| ๐ Matplotlib | Data visualization and graphs |
| ๐ฌ Ultralytics | YOLOv8 training and inference |
| ๐ง Reinforcement Learning | Intelligent signal timing optimization |
---
### ๐งช Backend โ **Core Logic & APIs**
| Tech | Purpose |
|------|---------|
| ๐ Flask | RESTful API backend (Python) |
| ๐ WebSocket (Flask-SocketIO) | Real-time data sync with frontend |
| ๐ MongoDB | NoSQL database for storing traffic history & logs |
| โ๏ธ Express.js + Node.js | API support for mobile & hardware integrations |
---
### ๐ Hardware โ **IoT-Powered Signal Controller**
| Component | Role |
|-----------|------|
| ๐ก Arduino UNO | Signal & sensor control unit |
| ๐ CZN15E Sound Sensor | Detects approaching emergency sirens |
| ๐ฅ OV7670 Camera Module | Captures live video for CV analysis |
| ๐ HC-SR04 Ultrasonic Sensor | Measures distance & lane occupancy |
| ๐ก LEDs, ๐งฒ Buzzer, ๐ Jumper Wires, ๐ณ Breadboard | Circuit components for signal light system |
| ๐ง Arduino IDE + Embedded C/C++ | Logic programming and testing |
| ๐ฅ๏ธ Serial Monitor | Debugging and communication with PC |
---
### ๐ฎ Bonus Tools & Utilities
| Tool | Use |
|------|-----|
| ๐งฉ Pygame | Simulating traffic flow for testing |
| ๐ Scikit-learn | Optional ML utilities |
| ๐งช Matplotlib | Data analysis visualization |
| ๐ง Gemini API | Optional AI assistance (integration idea) |
---
> ๐ Signal-X combines **real-world sensors**, **cutting-edge AI**, and **cloud-based data pipelines** to create a future-ready traffic management solution.
---
## ๐ Getting Started
### Prerequisites
- Python 3.8+
- Node.js and npm
- MongoDB
- MapmyIndia API key
- Gemini API key
- Arduino IDE
### Installation
1. **Clone the repository**
```bash
git clone https://github.com/ArshTiwari2004/Signal-X.git
cd Signal-X
```
2. **Setup Frontend**
```bash
cd traffic-monitoring/frontend/web/signalx-web
npm install
```
3. **Create a .env file in the root of the frontend directory with:**
```bash
VITE_MAPPLS_SDK_KEY=your_mapmy_india_sdk_key
```
4. **Start the development server:**
```
npm run dev
```
5. **Setup Backend - Create and activate a virtual environment:**
```
python -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # Linux/Mac
```
6. **Install the required packages:**
```
pip install -r requirements.txt
```
7. **Start the Flask server:**
```
python backend/flask_api.py
```
8. **For running the Expo project on mobile**
```
cd mobile-app/signalx-mobile
npm i
```
9. **Set up your GEMINI_API_KEY in .env**
```
VITE_GEMINI_API_KEY=your_gemini_api_key
```
10. **Run the app**
```
npx expo start
```
11. **Setting up the expo backend**
```
cd mobile-app/mobile-backend
npm i
```
12. **Set up env variables for expo backend**
```
TWILIO_ACCOUNT_SID=your_twilio_account_sid_here
TWILIO_AUTH_TOKEN=your_twilio_auth_token_here
TWILIO_PHONE_NUMBER=your_twilio_phone_number_here
MONGO_URI=your_mongodb_connection_string_here
```
13. **Run the Mobile Backend Server**
```
npm run dev
```
14. **Setup the Arduino IDE**
```bash
# โ๏ธ How to Upload
1. Open the `.ino` files using the Arduino IDE.
2. Select the correct board and port: - Tools > Board > (e.g., Arduino UNO) - Tools > Port > (Select the connected COM port)
3. Connect your Arduino (e.g., UNO, Nano, etc.) via USB.
4. Click the "Upload" button in the Arduino IDE (โก๏ธ icon).
5. Ensure all required components (Servo motors, LEDs, Buzzer, etc.) are connected as per the logic in the code.
```
# Project Structure
```bash
signal-x/
โโโ Arduino_code/
โ โโโ sketch_Camera/
โ โ โโโ sketch_Camera.ino # Controls CCTV pan/tilt
โ โโโ sketch_LED_Buzzer/
โ โโโ sketch_LED_Buzzer.ino # Controls signal lights & alarms
โ
โโโ mobile-app/
โ โโโ mobile-backend/
โ โ โโโ config/
โ โ โ โโโ db.js # MongoDB connection
โ โ โ โโโ dotenv.js # API keys config
โ โ โโโ models/
โ โ โ โโโ Incident.js # Report schema
โ โ โ โโโ User.js # Auth schema
โ โ โโโ routes/
โ โ โโโ authRoutes.js # Login/register endpoints
โ โ โโโ incidentRoutes.js # Report submission
โ โ
โ โโโ signalx-mobile/
โ โโโ components/
โ โ โโโ EmergencyAlert.js # Siren detection UI
โ โ โโโ LiveTrafficLight.js # Real-time signal status
โ โโโ screens/
โ โโโ HomeScreen.js # Main dashboard
โ โโโ ReportScreen.js # Incident form
โ
โโโ traffic-monitoring/
โ โโโ backend/
โ โ โโโ templates/ # Admin panel HTML
โ โ โโโ ambulance_detection.py # Priority vehicle logic
โ โ โโโ traffic_control.py # Signal timing algorithms
โ โ
โ โโโ frontend/
โ โ โโโ web/
โ โ โโโ signalx-web/
โ โ โโโ src/
โ โ โโโ components/ # Reusable UI elements
โ โ โโโ pages/ # Route-specific pages
โ โ โโโ routes/ # Navigation config
โ โ
โ โโโ models/ # AI models
โ โ โโโ yolov8n.pt # Vehicle detection weights
โ โ โโโ siren_detection.h5 # Audio classification
โ โ
โ โโโ simulations/ # Traffic simulations
โ โ โโโ rippling_effect.py # Congestion spread model
โ โ โโโ traffic_simulator.py # Junction flow simulator
โ โ
โ โโโ utils/ # Utility scripts
โ โ
โ โ
โ โ
โ โโโ alert.wav # Emergency sound
โ โโโ dashboard.png # Admin UI mockup
โ โโโ README.md # Setup instructions
```
## ๐ผ๏ธ Snippets
*Landing page of Signal-X*

*Dashboard of Signal-X*

*Auth workflow*

*Snapshots of the Citizen App*

## ๐ฎ Future Enhancements
## 1. **AI-Powered Red-Light Violation Detection** :
- Use AI-based license plate recognition to detect vehicles running red lights. Integrated with government databases, the system can auto-generate challans, improving law enforcement efficiency.
## 2. **Smart Signal Optimization with Reinforcement Learning**:
- Leverage reinforcement learning to optimize signal timings based on real-time and historical traffic data, ensuring faster clearance for emergency vehicles and smoother traffic flow.
## 3. **AI-Based Incident Detection & Rerouting**:
- Utilize AI to detect accidents or breakdowns via CCTV analysis. The system can instantly alert authorities and reroute traffic to prevent congestion.
## ๐ค Contributing
#### Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (git checkout -b feature/amazing-feature)
- Commit your changes (git commit -m 'Add some amazing feature')
- Push to the branch (git push origin feature/amazing-feature)
- Open a Pull Request
**โค๏ธ Made with love by Team Synapse โ Arsh Tiwari, Priyanshi Bothra, and Nibedan Pati**
๐ฉ Have a suggestion or want to connect? Drop a mail at: arshtiwari12345@gmail.com