Skip to content

VinitKumarGupta/CampusGuardAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚦 CampusGuard AI

Automated Traffic Monitoring & Enforcement System

Python YOLOv8 Django OpenCV

πŸ† Top 15 Finalist β€” IIT Bombay Techfest 2025 (Safetronics: Road Safety Challenge)


1. Overview

CampusGuard AI is a computer vision–based system designed to automate traffic monitoring inside university campuses and restricted zones.

Using existing CCTV cameras, the system can:

  • Track vehicles in real time

  • Estimate vehicle speed

  • Detect rule violations such as:

    • Over-speeding
    • Triple riding on two-wheelers
  • Automatically read license plates

  • Generate violation logs

  • Send SMS alerts to vehicle owners

  • Provide an administrative dashboard for monitoring

The system eliminates the need for expensive hardware such as radar guns or inductive sensors.

Demo

Real-time detection with bounding boxes and speed overlay Violation detection output

2. Problem Statement

Traffic monitoring inside campuses is usually done manually by security personnel.

This creates several issues:

  • Human error
  • Limited coverage
  • High manpower requirement
  • Delayed enforcement
  • No structured data collection

Most automated traffic systems require overhead cameras or specialized sensors, which are expensive and difficult to install.

CampusGuard AI solves this problem by working with existing side-view CCTV cameras.


3. System Architecture

The project consists of two independent components:

A. Computer Vision Engine (cv_engine)

Processes video feed and detects violations.

B. Django Dashboard (backend_dashboard)

Displays results and manages alerts.

Live CCTV Feed
      β”‚
      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   CV Engine (Python)        β”‚
β”‚  YOLOv8 β†’ ByteTrack         β”‚
β”‚        ↓                    β”‚
β”‚  Speed Estimation           β”‚
β”‚  Triple Riding Detection    β”‚
β”‚  Number Plate Recognition   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚ JSON Log
              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Django Dashboard           β”‚
β”‚  Violation records          β”‚
β”‚  Risk score calculation     β”‚
β”‚  SMS alerts (Twilio)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

4. Core Features

4.1 Speed Detection using Side-View Cameras

Most traffic systems require overhead cameras. CampusGuard AI works with side-view CCTV using a vector cross-product approach, making it deployable on any existing campus infrastructure.

  • Two reference lines $L_A$ and $L_B$ are defined in the image plane during a one-time calibration
  • Per frame, the system computes the sign of the cross-product of each tracked vehicle's centroid relative to each line
  • A sign change indicates a line-crossing event
  • Velocity is then computed as:

$$v = \frac{d}{\Delta t}$$

where $d = 4.9\text{m}$ (real-world calibrated distance) and $\Delta t$ is the frame delta at 30 FPS.


4.2 Triple Riding Detection

  1. Detect all Person and Motorcycle instances per frame via YOLOv8
  2. Compute the centroid of each Person bounding box
  3. Check strict spatial containment: is the centroid inside a Motorcycle bounding box?
  4. If the associated person count exceeds 2 β†’ violation flagged

4.3 Automatic Number Plate Recognition (ANPR)

License plates are detected and read automatically.

Pipeline:

Video Frame
     ↓
YOLOv8 Plate Detection
     ↓
Image Crop + Upscale
     ↓
EasyOCR Text Extraction
     ↓
Regex Validation (Indian format)
     ↓
Plate Number Logged

5. Technology Stack

Programming Language

  • Python 3.10+

Computer Vision

  • OpenCV
  • YOLOv8 (Ultralytics)
  • ByteTrack (Object tracking)
  • EasyOCR
  • NumPy

Backend

  • Django 5.2

Database

  • SQLite (development)
  • PostgreSQL (scalable deployment)

Notifications

  • Twilio API (SMS alerts)

6. Implementation Highlights

Feature Description
Detection model YOLOv8 (custom trained)
Tracking ByteTrack (maintains vehicle identity)
Speed estimation accuracy ~5.2% error margin
Camera requirement Works with side-view CCTV
OCR validation Indian license plate regex filtering
Architecture Modular & scalable

7. Project Structure

Key modules:

  • speed_estimator.py β†’ calculates vehicle speed using geometric crossing logic
  • plate_reader.py β†’ extracts license plate text using OCR
  • utils.py β†’ risk score calculation and gamification logic
  • main.py β†’ runs real-time CV pipeline
  • dashboard/ β†’ Django admin interface

8. Installation Guide

Requirements

  • Python 3.10+
  • CUDA-enabled GPU (recommended)

Step 1 β€” Clone Repository

git clone https://github.com/VinitKumarGupta/CampusGuardAI.git
cd campusguardai

Step 2 β€” Install Dependencies

pip install -r requirements.txt

Step 3 β€” Calibration

Define reference lines for speed detection (if using your own test video):

python get_line_coords.py

Update generated coordinates inside:

cv_engine/config.py

Step 4 β€” Run Computer Vision Engine

python cv_engine/main.py

Step 5 β€” Start Dashboard

cd backend_dashboard
python manage.py runserver

9. Future Improvements

  • Helmet detection
  • Night-time optimization
  • Cloud database integration
  • Multi-camera synchronization
  • Real-time analytics dashboard
  • Integration with campus security systems

Built by Vinit Kumar Gupta Β· PDEU, Gandhinagar

About

A real-time computer vision pipeline for automated traffic monitoring, featuring multi-class vehicle tracking, vector-based speed estimation, and license plate recognition served via a REST API.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors