Skip to content

ritiktyagiai/MLH-Hackathon-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚨 AI CCTV Intelligence System

An AI-powered surveillance analysis platform that transforms long CCTV footage into a structured, searchable timeline of events. Instead of manually reviewing hours of video, investigators receive AI-generated insights, summaries, and event detection in minutes.

Built using OpenCV, Gemini Vision API, FastAPI, and Streamlit.

πŸ“Œ The Problem

Modern cities generate massive amounts of CCTV footage every day.

Investigators and security teams often face challenges such as:

  • ⏱ Manually watching 6–10 hours of footage
  • πŸ”Ž Difficulty identifying critical moments in long recordings
  • πŸš— Trouble determining accident causes
  • πŸ•΅οΈ Slow investigation due to lack of structured evidence
  • πŸ“‚ No easy way to search events inside videos

For example:

After a road accident, police may need to review 8+ hours of CCTV footage just to find the exact moment and cause.

This process is time-consuming, inefficient, and prone to human error.

πŸ’‘ The Solution

The AI CCTV Intelligence System automatically analyzes CCTV footage and converts it into a timeline of meaningful events using AI.

Instead of watching hours of footage, users can:

  • View a timeline of detected events
  • Search events using natural language
  • Quickly understand what happened and when

It acts like an AI investigator for surveillance footage.

πŸš“ How It Helps Investigations

This system can significantly assist law enforcement, security teams, and investigators.

Accident Investigation

  • Detect vehicles, people, and unusual movements
  • Identify the exact moment an accident occurred
  • Provide visual evidence timeline

Crime Investigation

  • Detect suspicious activity
  • Track movement patterns
  • Quickly find important moments

Time Efficiency

Instead of watching 8 hours of video, investigators can review:

AI Generated Timeline
---------------------
08:12 AM β€” White car enters parking area
08:14 AM β€” Two individuals exit vehicle
08:16 AM β€” Suspicious movement near gate
08:18 AM β€” Motorcycle collision detected

This reduces investigation time from hours β†’ minutes.

✨ Key Features

πŸ“₯ Video Ingestion

Upload CCTV footage in formats such as:

  • .mp4
  • .mov
  • .avi

🎞 Video Frame Processing

Using OpenCV, the system extracts frames efficiently for analysis.

🧠 AI Vision Analysis

Powered by Gemini 2.5 Flash Vision, the system detects:

  • πŸ‘€ People
  • πŸš— Vehicles
  • πŸ“¦ Objects
  • ⚠ Suspicious movements
  • 🚨 Possible incidents

πŸ•’ Smart Timeline Generation

AI merges detections and creates a clean chronological event timeline.

Example output:

[
  {
    "time": "00:02:13",
    "event": "Person enters parking lot"
  },
  {
    "time": "00:04:55",
    "event": "Two vehicles collide"
  }
]

πŸ”Ž Natural Language Search

Users can search events like:

"Show when the accident happened"
"Find when a car entered"
"Suspicious activity near the gate"

The system instantly finds relevant moments.

πŸ“Š Interactive Dashboard

A Streamlit UI dashboard allows users to:

  • Upload videos
  • Track processing progress
  • View summaries
  • Filter events
  • Search the timeline

βš™οΈ System Architecture

CCTV Video
     β”‚
     β–Ό
Frame Extraction (OpenCV)
     β”‚
     β–Ό
AI Vision Analysis (Gemini)
     β”‚
     β–Ό
Event Detection
     β”‚
     β–Ό
Timeline Builder
     β”‚
     β–Ό
Search Engine + Dashboard

πŸ›  Tech Stack

Technology Purpose
Python Core development
OpenCV Frame extraction
Gemini Vision API AI video analysis
FastAPI Backend API
Streamlit Interactive frontend
JSON Timeline Engine Event structuring

πŸ“‚ Project Structure

AI_CCTV_Intelligence_System/
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── api_server.py
β”‚   β”‚
β”‚   β”œβ”€β”€ ai_analysis/
β”‚   β”‚   └── gemini_analyzer.py
β”‚   β”‚
β”‚   β”œβ”€β”€ search_engine/
β”‚   β”‚   └── search_engine.py
β”‚   β”‚
β”‚   β”œβ”€β”€ timeline_engine/
β”‚   β”‚   └── timeline_builder.py
β”‚   β”‚
β”‚   └── video_processing/
β”‚       β”œβ”€β”€ frame_extractor.py
β”‚       └── video_loader.py
β”‚
β”œβ”€β”€ frontend/
β”‚   └── frontend_app.py
β”‚
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ processed/
β”‚   └── uploads/
β”‚
β”œβ”€β”€ .env.example
β”œβ”€β”€ requirements.txt
└── README.md

⚑ Environment Setup

1️⃣ Requirements

Make sure you have:

Python 3.9+
pip
virtualenv (recommended)

2️⃣ Install Dependencies

pip install -r requirements.txt

3️⃣ Setup Environment Variables

Create a .env file in the root directory.

GEMINI_API_KEY=your_actual_api_key_here

▢️ Step-by-Step Run Guide

Step 1 β€” Start Backend Server

uvicorn backend.api.api_server:app --reload

Server will run at:

http://localhost:8000

Step 2 β€” Start Frontend Dashboard

Open another terminal:

streamlit run frontend/frontend_app.py

Streamlit will open at:

http://localhost:8501

Step 3 β€” Use the System

1️⃣ Open the Streamlit Dashboard

2️⃣ Upload a CCTV video

3️⃣ Click Upload and Analyze

4️⃣ Wait for AI processing

5️⃣ View:

  • πŸ“Š Video summary
  • πŸ•’ Event timeline
  • πŸ”Ž Search results

🌍 Real-World Applications

This system can be used in:

  • πŸš“ Police investigation
  • πŸ™ Smart city surveillance
  • 🏒 Corporate security monitoring
  • 🚦 Traffic accident analysis
  • πŸ›‘ Crime detection

πŸš€ Future Improvements

Possible next upgrades:

  • Real-time CCTV monitoring
  • Vehicle number plate recognition
  • Face recognition integration
  • Multi-camera tracking
  • Crime detection alerts
  • AI-generated incident reports

🧠 Inspiration

Security teams shouldn’t waste hours watching silent video footage.

This project aims to transform CCTV systems from passive recorders into intelligent investigative tools.

⭐ If You Like This Project

Give it a ⭐ on GitHub and help make AI-powered surveillance analysis smarter.

About

AI system that analyzes long CCTV footage and generates a smart timeline of events, helping police and investigators quickly detect accidents, vehicles, people, and suspicious activities.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages