
Beyond Simple Detection: Real-Time Event Reasoning for Safer Roads
Features • Architecture • Installation • Usage • Dashboard
Modern traffic monitoring systems face significant challenges:
- ❌ High False Positives: Traditional single-frame detection triggers incorrectly on shadows or static objects.
- ❌ Delayed Response: Manual surveillance cannot react instantly to critical hazards.
- ❌ Fragmented Data: Disconnected systems for violations, emergencies, and maintenance (potholes) create data silos.
- ❌ Lack of Context: Simple object detection fails to understand behavior over time (e.g., wrong-way driving).
CAMVIEW.AI moves beyond basic object detection. It is an Event-Driven Computer Vision System that transforms raw video feeds into structured, actionable safety intelligence.
By combining deep learning with temporal logic and an event bus architecture, it reasons about motion, context, and persistence to deliver enterprise-grade reliability.
- Temporal Tracking: Tracks vehicle motion vectors across multiple frames, not just single images.
- Lane-Aware Logic: Uses directional smoothing to confirm violations only after consistent behavior.
- False-Positive Suppression: Eliminates duplicate alerts for the same vehicle.
- Visual Recognition: Detects ambulances, fire trucks, and police vehicles using vision cues.
- Preemption Ready: Generates high-priority events designed for integration with smart traffic signals.
- Priority Logging: Flags events for immediate attention in the dashboard.
- Hazard Identification: Detects road surface irregularities in real-time.
- Severity Estimation: Automatically assigns severity (Low/Medium/High) based on hazard size/area.
- Maintenance Data: Provides structured logs for infrastructure planning.
- Decoupled Design: Separates Detection, Rules, and Actions.
- Internal Event Bus: Events flow asynchronously through the system.
- Extensible: Add new detectors (e.g., helmet detection) without rewriting the logging or UI code.
graph TD
A[Video Source] -->|Frames| B(Unified Processor)
B -->|Inference| C{YOLO Detectors}
C -->|Detections| D[Context & Rules Engine]
D -->|Valid Events| E[Event Bus]
E -->|Publish| F[JSONL Logger]
E -->|Publish| G[Firebase Cloud]
E -->|Publish| H[Console Alert]
subgraph Dashboard[Streamlit Enterprise Dashboard]
I[Real-Time Monitor]
J[Analytics Engine]
K[Data Export]
end
F -->|Read| Dashboard
G -->|Sync| Dashboard
| Component | Technology | Purpose |
|---|---|---|
| Core Logic | Python 3.10+ | Engine & Event Bus implementation |
| Vision | OpenCV | Video capture using hardware acceleration |
| AI Model | Ultralytics YOLO | Object Detection, Classification & Tracking |
| UI/UX | Streamlit | Real-time Enterprise Dashboard |
| Cloud | Firebase | Cloud syncing & Remote Monitoring (Optional) |
| Logging | JSONL | High-performance, append-only structured logs |
| Data | Pandas & Plotly | Advanced Analytics & Interactive Visualizations |
-
Clone the Repository
git clone https://github.com/your-username/CAMVIEW.AI.git cd CAMVIEW.AI -
Create Virtual Environment (Recommended)
# Windows python -m venv venv .\venv\Scripts\activate # Linux / macOS python3 -m venv venv source venv/bin/activate
-
Install Dependencies
pip install -r requirements.txt
Note: First run will automatically download necessary YOLO models.
Start the backend detection engine. This processes video and generates events.
# Use Webcam
python main.py --source 0
# Use Video File
python main.py --source data/raw/traffic_video.mp4Open a new terminal to run the visualization interface.
streamlit run app.pyAccess the dashboard at http://localhost:8501
The system includes a Streamlit-based Enterprise Dashboard:
- Live Preview: Low-latency video feed with bounding box overlays.
- Event Feed: Real-time scrolling log of violations and hazards.
- Analytics Tab: Interactive charts for Event Type Distribution, Severity Timeline, and Hourly Heatmaps.
- Data Export: Download logs in CSV, JSON, or Excel formats.
We believe in honest engineering. Current system constraints:
- Streamlit FPS: Optimized for stability over raw speed (approx 5-10 FPS preview).
- Geo-Tagging: Pothole locations are currently relative to the frame, not GPS coordinates.
- Lighting: Performance may decrease in extreme low-light conditions without IR cameras.
- GPS Integration: Better Integration of Google Maps API for real-world pothole plotting.
- RTSP Support: Native integration for IP Security Cameras.
- WebRTC: Lower latency video streaming for the dashboard.
- Edge Deployment: Optimization for Jetson Nano / Raspberry Pi 5.
© 2026 CAMVIEW.AI • Engineering Safety Intelligence
- Install Dependencies:
(Note:
pip install -r requirements.txt
ultralyticswill automatically download the YOLOv8 model on first run).
This runs the main detection loop and prints alerts to the console.
# Run with webcam
python main.py --source 0
# Run with a video file
python main.py --source data/raw/traffic_video.mp4Open a separate terminal to view the live dashboard.
streamlit run app.pycore/: Core engine, Event Bus, and Event definitions.detectors/: Specific logic for each problem statement (Wrong-side, etc.).config/: Settings and constants.data/logs/: Storesevents.jsonlfor the dashboard.
Built with ❤️ for the Future of Traffic System by Ahad Dangarvawala