Skip to content
Astik97Public

About

Edge AI Crime Detection and Emergency Alert System using YOLOv8, Flask, Raspberry Pi and Twilio APIs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

52 Commits

Folders and files

Repository files navigation

FALCON Banner

πŸ¦… FALCON

Automatic Crime Alert and Reporting System

Real-Time Weapon Detection using YOLOv8 β€’ Flask β€’ OpenCV β€’ Raspberry Pi β€’ Twilio

Python Flask YOLOv8 OpenCV SQLite Twilio Raspberry Pi License


πŸ“‘ Table of Contents

  • Overview
  • Problem Statement
  • Solution
  • Features
  • System Architecture
  • Detection Methodology
  • Technology Stack
  • Hardware Requirements
  • Software Requirements
  • Project Structure
  • Screenshots
  • Installation
  • Configuration
  • Running the Project
  • Workflow
  • Model Performance
  • Security
  • Limitations
  • Future Roadmap
  • Contributing
  • License
  • Author

πŸ“– Overview

FALCON (Automatic Crime Alert and Reporting System) is an AI-powered surveillance and emergency response platform designed to detect dangerous objects such as weapons in real-time using computer vision and deep learning techniques.

The system uses a custom-trained YOLOv8 object detection model to analyze live camera feeds, identify potential threats, capture evidence, store detection records, and automatically notify authorized personnel through Twilio SMS alerts.

Unlike traditional CCTV systems that only record incidents and require continuous human monitoring, FALCON performs automated threat detection and rapid response using Artificial Intelligence.

The system combines:

  • Computer Vision
  • Deep Learning
  • Edge AI Processing
  • Real-Time Video Analysis
  • Backend Development
  • Database Management
  • Automated Alert Generation

The project is designed for real-world surveillance applications including smart security systems, public safety monitoring, and emergency response solutions.


❗ Problem Statement

Traditional CCTV surveillance systems only provide video recording capabilities.

Although cameras continuously monitor environments, identifying dangerous activities still depends on human operators. This creates several problems:

  • Delayed threat identification
  • Slow emergency response
  • Human monitoring limitations
  • Difficulty reviewing large amounts of recorded footage
  • Lack of automated incident reporting

In critical situations involving weapons or violent activities, even a few seconds of delay can increase the severity of an incident.

FALCON addresses this challenge by introducing an AI-based automated surveillance system capable of detecting threats, generating alerts, and maintaining digital incident records.


πŸ’‘ Solution

FALCON provides an automated AI surveillance pipeline:

  1. Camera captures live video input.

  2. OpenCV extracts video frames.

  3. YOLOv8 analyzes each frame for weapon detection.

  4. Detection results are evaluated using confidence thresholds.

  5. When a threat is detected:

    • Evidence image is captured
    • Detection information is stored
    • Incident details are recorded
    • Twilio sends SMS alerts
    • Dashboard is updated

The system continuously monitors the environment and performs real-time threat detection without requiring constant human supervision.


✨ Features

πŸ€– AI-Based Weapon Detection

  • Real-time weapon detection using YOLOv8
  • Custom-trained object detection model
  • Bounding box visualization
  • Confidence score calculation
  • Image and video evidence capture
  • Automated threat identification

πŸŽ₯ Real-Time Surveillance

  • USB camera support
  • RTSP/IP camera support
  • Live video stream processing
  • Frame-by-frame AI analysis
  • Raspberry Pi compatible edge deployment

🚨 Automated Alert System

  • Instant SMS notification using Twilio API
  • Threat detection timestamp
  • Detection information sharing
  • Emergency response notification

πŸ“Š Dashboard and Reporting

  • Web-based monitoring dashboard
  • Detection history tracking
  • Incident reports
  • Captured evidence management
  • Detection statistics

πŸ‘€ Authentication System

  • User registration
  • Secure login system
  • Password encryption
  • Session management
  • Protected dashboard access

πŸ—„ Database Management

  • SQLite database integration
  • Detection record storage
  • Alert history management
  • User information management

πŸ–₯ Edge AI Deployment

  • Raspberry Pi compatible architecture
  • Local AI inference
  • Reduced response latency
  • No dependency on cloud processing
  • Better privacy and security

πŸ— System Architecture

                    IP Camera / USB Camera
                            β”‚
                            β–Ό
                    RTSP Video Stream
                            β”‚
                            β–Ό
                    OpenCV Frame Capture
                            β”‚
                            β–Ό
                    Image Preprocessing
                            β”‚
                            β–Ό
                    YOLOv8 Detection Model
                            β”‚
                            β–Ό
                 Object + Confidence Analysis
                            β”‚
                            β–Ό
                    Threat Decision Logic
                            β”‚
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β–Ό                             β–Ό

     Capture Evidence              Generate Alert
     Image / Video                 Twilio SMS

             β”‚                             β”‚
             β–Ό                             β–Ό

        SQLite Database             Emergency Contact

             β”‚
             β–Ό

       Flask Web Dashboard

             β”‚
             β–Ό

     Reports and Incident History

The complete system works as a continuous AI surveillance loop:

Camera Input β†’ Frame Processing β†’ Object Detection β†’ Threat Analysis β†’ Evidence Storage β†’ Alert Generation β†’ Reporting

🧠 Detection Methodology

1. Video Input Acquisition

The system receives live video input from:

  • IP Camera through RTSP protocol
  • USB Camera

RTSP provides continuous real-time video transmission with low delay.

2. Frame Extraction

OpenCV captures the incoming video stream and converts it into individual frames.

Example:

30 FPS video = 30 individual images processed every second.

3. Image Preprocessing

Before AI processing:

  • Frames are resized
  • Pixel values are optimized
  • Input format is prepared for YOLOv8

4. YOLOv8 Object Detection

The YOLOv8 model analyzes each frame and identifies possible weapons.

The model returns:

  • Object class
  • Bounding box coordinates
  • Confidence score

Example:

Weapon Detected

Confidence: 92%

5. Threat Decision Logic

The system does not generate alerts for every detection.

A confidence threshold is applied:

Example:

Confidence > 60%

AND

Object = Weapon

Then:

Threat Confirmed

6. Evidence Generation

After threat confirmation:

  • Detection image is captured
  • Bounding box is stored
  • Timestamp is recorded
  • Incident data is saved

7. Alert Generation

The Flask backend triggers Twilio SMS notification containing:

  • Threat information
  • Detection time
  • Camera information

8. Database Storage

Detection information is stored in SQLite:

  • Date and time
  • Detected object
  • Confidence score
  • Evidence path

πŸ›  Technology Stack

Layer Technology
Programming Language Python
Backend Framework Flask
Frontend HTML, CSS, JavaScript
AI Model YOLOv8 (Ultralytics)
Computer Vision OpenCV
Deep Learning Framework PyTorch
Database SQLite
Camera Streaming RTSP
Alert System Twilio API
Dataset Annotation Roboflow
Hardware Deployment Raspberry Pi
Version Control Git & GitHub

πŸ”© Hardware Requirements

Development System

Recommended:

  • Processor: Intel i5 / Ryzen 5 or above
  • RAM: 8GB minimum
  • Storage: 10GB+ free space
  • Operating System: Windows/Linux

Edge Deployment System

Raspberry Pi 5

Specifications:

  • Raspberry Pi 5
  • 8GB RAM
  • Camera module/IP Camera
  • MicroSD Card
  • Power supply
  • Network connectivity

Camera Requirements

Supported:

  • USB Camera
  • IP Camera
  • RTSP-enabled CCTV Camera

πŸ’» Software Requirements

  • Python 3.10+
  • Flask
  • OpenCV
  • Ultralytics YOLOv8
  • PyTorch
  • SQLite
  • Twilio API
  • Git
  • Visual Studio Code

πŸ“‚ Project Structure

FALCON/

β”‚ β”œβ”€β”€ AI/ β”‚ β”‚ β”‚ β”œβ”€β”€ init.py β”‚ β”œβ”€β”€ yolo_detect.py β”‚ β”œβ”€β”€ live_rtsp_detector.py β”‚ β”œβ”€β”€ train_yolo.py β”‚ β”‚ β”‚ └── models/ β”‚ └── best.pt β”‚ β”œβ”€β”€ alerts/ β”‚ β”‚ β”‚ β”œβ”€β”€ init.py β”‚ └── twilio_alert.py β”‚ β”œβ”€β”€ database/ β”‚ β”‚ β”‚ β”œβ”€β”€ init.py β”‚ β”œβ”€β”€ detection_db.py β”‚ β”œβ”€β”€ alert_db.py β”‚ β”œβ”€β”€ add_users.db β”‚ β”œβ”€β”€ detections.db β”‚ └── alerts.db β”‚ β”œβ”€β”€ media/ β”‚ β”‚ β”‚ └── output/ β”‚ β”œβ”€β”€ screenshots/ β”‚ β”œβ”€β”€ static/ β”‚ β”œβ”€β”€ templates/ β”‚ β”œβ”€β”€ train_detect_weapons/ β”‚ β”‚ β”‚ β”œβ”€β”€ data.yaml β”‚ └── dataset/ β”‚ β”œβ”€β”€ app.py β”œβ”€β”€ config.py β”œβ”€β”€ run.py β”œβ”€β”€ requirements.txt β”œβ”€β”€ .env β”œβ”€β”€ .gitignore └── README.md


Screenshots

Login

Login

Register

Register

Dashboard

Dashboard

Detection Report

Report

Alert

Alert


βš™ Installation

git clone https://github.com/Astik97/FALCON.git

cd FALCON

Create virtual environment

Windows

python -m venv venv
venv\Scripts\activate

Linux

python3 -m venv venv
source venv/bin/activate

Install dependencies

pip install -r requirements.txt

πŸ” Environment Variables

Create a .env file inside the project root directory.

Example:

SECRET_KEY=your_secret_key

MODEL_PATH=AI/models/best.pt

# Twilio Configuration

TWILIO_ACCOUNT_SID=your_account_sid

TWILIO_AUTH_TOKEN=your_auth_token

TWILIO_PHONE_NUMBER=your_twilio_number

ALERT_RECEIVER_NUMBER=receiver_number

β–Ά Running the Project

python app.py

Open

http://127.0.0.1:5000

FALCON provides a central launcher using run.py.

Start the system:

python run.py

πŸ”„ Workflow


                Start System

                     β”‚

                     β–Ό

             Camera Initialization

                     β”‚

                     β–Ό

             OpenCV Video Capture

                     β”‚

                     β–Ό

              Extract Video Frames

                     β”‚

                     β–Ό

              YOLOv8 Prediction

                     β”‚

                     β–Ό

        Weapon Object Detected?

              β”‚              β”‚

             No             Yes

              β”‚              β”‚

              β”‚              β–Ό

              β”‚       Capture Evidence

              β”‚              β”‚

              β”‚              β–Ό

              β”‚       Save Image/Video

              β”‚              β”‚

              β”‚              β–Ό

              β”‚       Store Detection Data

              β”‚              β”‚

              β”‚              β–Ό

              β”‚       Twilio SMS Alert

              β”‚              β”‚

              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

                     β”‚

                     β–Ό

            Update Dashboard

                     β”‚

                     β–Ό

             Generate Reports


πŸ“ˆ Model Performance

Metric Value
Model YOLOv8
Dataset Custom Weapon Dataset
Annotation Tool Roboflow
Training Framework Ultralytics
Image Size 640x640
Epochs 50
Precision 85%
Recall 75%
mAP@0.5 81%

Performance may vary depending on:

  • Hardware capability
  • Camera quality
  • Lighting conditions
  • Detection confidence threshold
  • Model optimization

⚑ Performance Benchmark

Device FPS Latency Expected Capability
GPU System 15–25 40–60 ms Faster YOLO inference
Desktop CPU 5–10 120–200 ms Development and testing
Raspberry Pi 1–3 400–800 ms Edge AI deployment with optimization

Performance depends on:

  • YOLO model size
  • Input resolution
  • Camera FPS
  • Optimization method
  • Hardware acceleration

πŸ”’ Security

FALCON follows security practices to protect system data, credentials, and access.

Authentication Security

  • User registration system
  • Password hashing
  • Secure session management
  • Protected dashboard access

Data Security

  • Environment variables used for sensitive credentials
  • API keys excluded from GitHub
  • Database access controlled through backend modules
  • Secure configuration management

AI System Security

  • Local inference support
  • Reduced dependency on external cloud services
  • Evidence stored locally
  • Controlled access to detection records

Deployment Security

Recommended production improvements:

  • HTTPS implementation
  • Firewall configuration
  • Role-based access control
  • Database encryption
  • Secure API authentication

⚠ Limitations

Although FALCON provides automated AI-based surveillance, some limitations exist:

Detection Limitations

  • Accuracy depends on dataset quality
  • False positives may occur
  • Poor lighting can reduce detection performance
  • Small or hidden objects may be difficult to detect

Hardware Limitations

  • Raspberry Pi has limited computational power
  • High-resolution streams require optimization
  • Multiple camera processing requires additional resources

Environmental Limitations

  • Camera positioning affects detection accuracy
  • Network stability is required for RTSP cameras
  • Extreme weather conditions may affect camera performance

Alert Limitations

  • Twilio requires internet connectivity
  • SMS delivery depends on network availability

πŸ—Ί Future Roadmap

FALCON is designed as an expandable AI surveillance platform.

Future development will focus on improving intelligence, scalability, and real-world deployment.

Phase 1: System Improvement

Backend and AI Enhancement

  • Improve YOLOv8 model accuracy
  • Increase detection speed
  • Optimize database operations
  • Improve dashboard analytics
  • Add advanced reporting system
  • Improve authentication security

Phase 2: Edge AI Deployment

Raspberry Pi Production Deployment

  • Deploy complete system on Raspberry Pi 5
  • Optimize YOLO using ONNX
  • TensorRT acceleration support
  • Multi-camera monitoring
  • Real-time WebSocket communication
  • Offline edge inference

Phase 3: Advanced AI Surveillance

Intelligent Threat Analysis

  • Person detection and tracking
  • Suspicious activity detection
  • Behaviour analysis
  • Threat scoring system
  • Multiple object tracking
  • Crime pattern analysis

Phase 4: Smart City and Enterprise Deployment

Large Scale Architecture

  • Cloud deployment
  • Distributed surveillance network
  • Mobile application
  • GPS location tracking
  • Google Maps integration
  • Enterprise monitoring dashboard
  • Smart city security integration

🀝 Contributing

Contributions, issues, and feature requests are welcome.

Steps:

Fork the repository.

Create a feature branch.

Commit your changes.

Open a Pull Request.

git checkout -b feature/new-feature

πŸ“„ License

This project is licensed under the MIT License.

You are free to:

  • Use
  • Modify
  • Distribute
  • Improve

provided that proper credit is given.


πŸ‘¨β€πŸ’» Author

Astik Mohapatra

Backend Developer β€’ AI Systems Developer β€’ Computer Vision Enthusiast

πŸ“§ Email:

astikm7007@gmail.com

πŸ”— LinkedIn

https://linkedin.com/in/astik-mohapatra

πŸ™ GitHub

https://github.com/Astik97


⭐ Support

If you find this project useful:

⭐ Star the repository

🍴 Fork the repository

πŸ“’ Share the project

Built with:

Python β€’ YOLOv8 β€’ OpenCV β€’ Flask β€’ SQLite β€’ Twilio β€’ Raspberry Pi

πŸ¦… FALCON

Automatic Crime Alert and Reporting System

About

Edge AI Crime Detection and Emergency Alert System using YOLOv8, Flask, Raspberry Pi and Twilio APIs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages