Skip to content

Repository files navigation

🚦 Traffic Surveillance Project

A two-server traffic enforcement system that helps traffic officers verify driver and vehicle information quickly using OCR, computer vision, and a centralized MySQL database.

The project has three main parts:

  • Dummy Data Setup — prepares the MySQL schema and sample records used by the system.
  • Server 1: Django (DL_Detection) — handles driver’s license image upload, OCR extraction, database lookup, and API responses.
  • Server 2: Flask (Number Plate Detection) — monitors live camera input, detects number plates in real time, and fetches vehicle details from Server 1.

📌 What this project does

This project automates two important traffic enforcement workflows:

  1. Driver’s License Detection

    • Upload a driver’s license image.
    • Extract details using OCR.
    • Match the extracted data against the database.
    • Show owner, license, vehicle, and face details.
  2. Number Plate Detection

    • Read live vehicle feed from an IP camera.
    • Detect number plates in real time using a pre-trained YOLO model.
    • Cross-check the plate against the database.
    • Flag suspicious, expired, or wanted records for officers.

🧱 Repository Structure

Traffic_surveillance_Project/
├── 1_DummyData/
├── 2_DL_Detection_Server1/
├── 3_NumberPlate_Detection_Server2/
└── TrafficSurveillanceProject_Wireframe_ss/

Folder roles

  • 1_DummyData/
    Contains MySQL schema and database import instructions for the sample dataset used by both servers.

  • 2_DL_Detection_Server1/
    Django backend for driver’s license detection, OCR, admin access, and APIs.

  • 3_NumberPlate_Detection_Server2/
    Flask application for live number plate detection and real-time alerts.

  • TrafficSurveillanceProject_Wireframe_ss/
    Contains architecture diagrams, schema diagram, and UI preview screenshots.


🧠 High-level architecture

Mobile / IP Camera
        │
        ▼
Flask Server (Number Plate Detection)
        │
        ├── detects plate in live feed
        ├── flags vehicle status
        ▼
Django Server (DL Detection / API Layer)
        │
        ├── database lookup
        ├── vehicle + license data
        ├── face image / suspicious status
        ▼
MySQL Database

How the two servers work together

  • Server 2 continuously watches the road feed.
  • When a plate is detected, Server 2 calls Server 1 API.
  • Server 1 reads the database and returns the relevant vehicle/driver details.
  • The Flask UI displays the result instantly for traffic officers.

⚙️ Tech Stack

  • Frontend/UI: Django templates, Flask templates
  • Backend: Django, Flask
  • Database: MySQL
  • Computer Vision: OpenCV, YOLO
  • OCR: Tesseract OCR
  • Integration: REST APIs, IP camera stream, ngrok for public tunneling when needed

🚀 Setup Overview

1) Dummy Data

Use the dummy data folder to create and populate the MySQL database.

  • Create the database schema
  • Insert sample records
  • Ensure both servers can query the same dataset

2) Server 1 — Django

Server 1 provides:

  • Driver’s license image upload
  • OCR-based extraction
  • Database lookup
  • APIs for vehicle details and license details
  • Optional Django admin panel for managing records

3) Server 2 — Flask

Server 2 provides:

  • Live number plate detection
  • Real-time vehicle flagging
  • Officer-facing monitoring interface
  • On-demand fetching of vehicle details from Django

Both servers should point to the same MySQL database and should be configured with the correct local or ngrok URL when needed.


🔌 API Flow

Django API endpoints

  • POST /get_vehicle_details/

    • Input: number plate
    • Output: vehicle details, suspicious status, face image URL
  • POST /get_data_from_license_image/

    • Input: license image file
    • Output: owner details, DL details, vehicle details, suspicious person details, face image URL

Flask integration

  • Flask sends the detected number plate to Django.
  • Django returns the vehicle and person status.
  • Flask shows the status on the monitoring page.

🎯 Status Color Meaning

  • Green & Yellow → minor felony such as expired PUC
  • Orange → bad history
  • Red → wanted currently

🖼️ Architecture & Schema

Project Architecture

Architecture

Project Database Schema

DatabaseSchema


📱 DL Detection — Mobile UI Preview

Landing page

DL Detection Landing Page

License details previews

Person 1 Details Green
Person 1 — Green
Person 1 Details Continued Green
Person 1 — Continued
Person 2 Details Orange
Person 2 — Orange
Person 2 Details Continued Orange
Person 2 — Continued
Person 3 Details Red
Person 3 — Red
Person 3 Details Continued Red
Person 3 — Continued

Recently accessed persons

Recently Accessed Persons List


🚔 Number Plate Detection — Mobile UI Preview

Detection flow

Detecting 1st flagged car
Detecting 1st flagged car
Detecting 2nd flagged car
Detecting 2nd flagged car
Detecting 4th flagged car
Detecting 4th flagged car
Flagged vehicle details yellow
Vehicle details — Yellow
Flagged vehicle details orange
Vehicle details — Orange
Flagged vehicle details red
Vehicle details — Red

🧩 Project Summary

This project combines database-driven verification and real-time computer vision to assist traffic officers in making faster and more reliable decisions.

  • Server 1 focuses on driver identity and document verification.
  • Server 2 focuses on live road monitoring and vehicle flagging.
  • MySQL acts as the shared data layer.
  • The UI is designed for practical, mobile-friendly field usage.

📎 Notes

  • Use the correct local IP or ngrok URL when connecting Server 2 to Server 1.
  • Make sure the phone camera and laptop are on the same Wi-Fi network for live stream-based use.
  • The same database must be available to both servers.
  • Tesseract OCR and YOLO dependencies must be installed correctly for the two detection flows.

✨ Too cool to miss planning diagrams

The planning-stage diagrams below were created during early design work and are included here as a nice record of the project’s evolution, even though they are not central to the current runtime scope.

Project Flow Details

Project Flow Details

Planning Stage — Device & Implementation Details

Planning Stage — Device & Implementation Details

About

Smart traffic monitoring system that detects number plates in real-time and verifies driver/license data using OCR and a centralized database.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages