Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚦 SpeedRadar-ANPR

AI-Powered Speed Enforcement & Automatic Number Plate Recognition System

Python YOLO11 PaddleOCR OpenCV License

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.


📸 Screenshot

SpeedRadar-ANPR Report Screenshot

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.

📑 Table of Contents


🌟 Features

🚗 Real-Time Vehicle Detection & Tracking

  • Detects vehicles using YOLO11.
  • Tracks vehicles across frames using ByteTrack.
  • Assigns a unique ID to every detected vehicle.

📏 Dynamic Velocity Estimation

  • 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.

🎯 Proximity-Aware OCR

  • 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.

🔁 Multi-Frame OCR Retry Mechanism

  • Attempts OCR across multiple frames if the initial read fails.
  • Uses Regex filtering to validate plate formats.
  • Selects the highest-confidence plate reading.

💰 Automated Fine Calculation

  • Dynamically calculates fines according to configurable speed limits.
  • Supports multiple violation brackets.

📸 Watermarked Visual Evidence

Automatically generates evidence images containing:

  • Vehicle snapshot
  • Measured speed
  • License plate number
  • Fine amount
  • Timestamp

🏷 Plate-Named Evidence Storage

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

📄 Automatic Violation Reports

Generates a Markdown report containing:

  • Vehicle ID
  • License plate number
  • Vehicle speed
  • Speed limit
  • Fine amount
  • Total revenue generated from fines

🏗 Architecture

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

🎥 Demo

The repository includes a sample traffic video for quick testing:

traffic_video/
└── sample_video.mp4

Simply run:

python main.py

and 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

⚙️ Installation

Prerequisites

  • Python 3.10+
  • CUDA GPU (Optional but recommended)

Clone Repository

git clone https://github.com/usfahmed/SpeedRadar-ANPR.git
cd SpeedRadar-ANPR

Install Dependencies

pip install -r requirements.txt

Install PaddlePaddle

CPU Version

pip install paddlepaddle

GPU Version

Install the version compatible with your CUDA installation.


🚀 Usage

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.py

Enter the desired speed limit when prompted:

Enter speed limit: 60

After processing is complete:

📁 output/

Contains the fully annotated processed video.

📁 proof/

Contains watermarked evidence images named using the detected license plate number.

Example:

proof/
├── ABC1234.jpg
├── XYZ5678.jpg
└── DEF9012.jpg

📄 report.md

Contains the generated violation report.


📂 Project Structure

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

⚠ Challenges & Solutions

Problem

Stationary vehicles occasionally generated false speed readings because of tracker jitter.

Solution

Implemented motion-distance filtering before speed calculation.


Problem

OCR accuracy dropped significantly for distant vehicles.

Solution

Implemented proximity-aware OCR triggering based on bounding box size.


Problem

Motion blur occasionally caused OCR failures.

Solution

Implemented multi-frame OCR retries with confidence scoring and Regex validation.


🔮 Future Improvements

  • Multi-camera support
  • Real-time dashboard
  • Database integration
  • REST API support
  • Cloud deployment
  • Vehicle classification
  • Traffic statistics dashboard
  • Heatmap generation
  • Email notifications
  • SMS notifications

🛠 Technologies Used

Programming Language

  • Python

Object Detection

  • YOLO11

Multi-Object Tracking

  • ByteTrack

OCR

  • PaddleOCR

Computer Vision

  • OpenCV
  • NumPy

Data Processing

  • Pandas

Reporting

  • Markdown

📄 License

This project is licensed under the MIT License.

See the LICENSE file for more details.


⚠ Disclaimer

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.


📫 Contact

Youssef Ahmed Abdelfatah

🌐 Portfolio
https://usfahmed.dev

💻 GitHub
https://github.com/usfa7med

💼 LinkedIn
https://linkedin.com/in/usfa7med

✉️ Email
hello@usfahmed.dev

About

AI-powered speed enforcement & ANPR system. Detects and tracks vehicles using YOLO11 + ByteTrack, estimates speed from pixel displacement, extracts plates with PaddleOCR, and generates watermarked evidence, violation reports, and calculated fines.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages