An end-to-end Computer Vision pipeline for automated traffic monitoring, speed enforcement, and automatic license plate recognition.
The system detects and tracks vehicles in real-time, estimates their speed, identifies speed violations, extracts license plate information using OCR, generates visual evidence for offenders, and automatically produces violation reports.
The screenshot above shows a completed run of the pipeline on the sample traffic video — the live terminal output detecting each violation in real time (speed, plate, fine) alongside the final auto-generated `report.md`, which lists all 5 detected violations with their speed, plate number, fine amount, and a link to the corresponding proof image.
- Features
- Architecture
- Demo
- Installation
- Usage
- Project Structure
- Challenges & Solutions
- Future Improvements
- Technologies Used
- License
- Disclaimer
- Contact
- Detects vehicles using YOLO11.
- Tracks vehicles across frames using ByteTrack.
- Assigns a unique ID to every detected vehicle.
- Calculates vehicle speed using pixel displacement and frame timing.
- Converts image-space movement into real-world speed estimates.
- Uses motion filtering to eliminate speed jitter caused by stationary vehicles.
- Runs the license plate recognition pipeline only when the vehicle is sufficiently close to the camera.
- Reduces OCR failures caused by distant or low-resolution plates.
- Improves overall ANPR accuracy.
- Attempts OCR across multiple frames if the initial read fails.
- Uses Regex filtering to validate plate formats.
- Selects the highest-confidence plate reading.
- Dynamically calculates fines according to configurable speed limits.
- Supports multiple violation brackets.
Automatically generates evidence images containing:
- Vehicle snapshot
- Measured speed
- License plate number
- Fine amount
- Timestamp
Evidence images are automatically saved using the detected license plate number as the filename for fast lookup and traceability.
Example:
proof/
├── ABC1234.jpg
├── XYZ5678.jpg
└── DEF9012.jpg
Generates a Markdown report containing:
- Vehicle ID
- License plate number
- Vehicle speed
- Speed limit
- Fine amount
- Total revenue generated from fines
Traffic Video
│
▼
YOLO11 Vehicle Detection
│
▼
ByteTrack Tracking
│
▼
Speed Estimation
│
▼
Speed Limit Check
│
┌────┴────┐
│Violation│
└────┬────┘
▼
License Plate Detection
▼
PaddleOCR Recognition
▼
Regex Validation
▼
Fine Calculation
▼
Evidence Generation
▼
Markdown Report
The repository includes a sample traffic video for quick testing:
traffic_video/
└── sample_video.mp4
Simply run:
python main.pyand the system will process the included sample video automatically.
The repository also contains:
assets/
└── photo.png
which showcases an example of the generated visual evidence produced by the system.
A complete demonstration video showing:
- Vehicle Detection
- Vehicle Tracking
- Speed Estimation
- License Plate Recognition
- Fine Calculation
- Evidence Generation
- Report Creation
is available here:
https://drive.google.com/drive/folders/1RB6IiRvOlSUCQAtKY5DU89HfoJKRaABN?usp=sharing
Example outputs:
output/
└── output_video.mp4
proof/
├── ABC1234.jpg
├── XYZ5678.jpg
└── DEF9012.jpg
report.md
- Python 3.10+
- CUDA GPU (Optional but recommended)
git clone https://github.com/usfahmed/SpeedRadar-ANPR.git
cd SpeedRadar-ANPRpip install -r requirements.txtpip install paddlepaddleInstall the version compatible with your CUDA installation.
The repository already includes a sample traffic video:
traffic_video/
└── sample_video.mp4
You may replace it with your own footage if desired.
Run the application:
python main.pyEnter the desired speed limit when prompted:
Enter speed limit: 60
After processing is complete:
Contains the fully annotated processed video.
Contains watermarked evidence images named using the detected license plate number.
Example:
proof/
├── ABC1234.jpg
├── XYZ5678.jpg
└── DEF9012.jpg
Contains the generated violation report.
SpeedRadar-ANPR/
│
├── assets/
│ └── photo.png
│
├── detections/
│ ├── __init__.py
│ ├── car_detection.py
│ └── licence_plate_detection.py
│
├── models/
│ ├── best.pt
│ └── yolo11n.pt
│
├── output/
│
├── proof/
│
├── traffic_video/
│ └── sample_video.mp4
│
├── utils/
│ ├── __init__.py
│ └── video_utils.py
│
├── LICENSE
├── main.py
├── README.md
└── requirements.txt
Stationary vehicles occasionally generated false speed readings because of tracker jitter.
Implemented motion-distance filtering before speed calculation.
OCR accuracy dropped significantly for distant vehicles.
Implemented proximity-aware OCR triggering based on bounding box size.
Motion blur occasionally caused OCR failures.
Implemented multi-frame OCR retries with confidence scoring and Regex validation.
- Multi-camera support
- Real-time dashboard
- Database integration
- REST API support
- Cloud deployment
- Vehicle classification
- Traffic statistics dashboard
- Heatmap generation
- Email notifications
- SMS notifications
- Python
- YOLO11
- ByteTrack
- PaddleOCR
- OpenCV
- NumPy
- Pandas
- Markdown
This project is licensed under the MIT License.
See the LICENSE file for more details.
This project was developed for educational and research purposes only.
It is not intended for deployment in real-world law enforcement systems without proper calibration, validation, legal approval, and regulatory compliance.
Youssef Ahmed Abdelfatah
🌐 Portfolio
https://usfahmed.dev
💻 GitHub
https://github.com/usfa7med
💼 LinkedIn
https://linkedin.com/in/usfa7med
✉️ Email
hello@usfahmed.dev
