Skip to content

About

A production-grade Perimeter Security platform using YOLOv5 and Flask. Features an AI Tripwire, async disk maintenance, and persistent SQL logging.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

📘 Chapter 9: YOLOv5 AI Tripwire Perimeter Security & Telemetry Engine

This project deploys a production-grade Perimeter Security, Localized UI, and Spatial Analytics application using YOLOv5. It is seamlessly integrated into a Flask web server to achieve local multi-address video streaming, intelligent threshold profiling, persistent data logging, and automated disk space maintenance.


🛠️ Advanced Key Features

  • AI Tripwire Border Control: Implements a virtual security line mapped directly onto the video matrix at 65% of the Y-axis. The framework calculates target centroids mathematically and triggers security protocols only when an object breaches the line.
  • Dual HUD Telemetry Overlay: Embedded real-time execution analytics drawn directly onto mutable image frames, displaying current System Status (SECURED / ALERT), Pipeline Frame-Rate (FPS), and CPU Inference Speed in milliseconds.
  • Localized Translation Gateway: Built-in dynamic class localization mapping native English COCO labels to clear Romanian descriptions (Vaza, Planta_ghiveci) across both the web interface HUD and the automated snapshot naming engine.
  • Thread-Safe Shared Disk Storage: Utilizes isolated file paths and custom I/O backend pipelines (cv2.CAP_FFMPEG) to prevent thread locking or file corruption inside Windows environments during fast automated snapshot file creation.
  • Incident-Driven Storage Buffer: Features a rate-limiting timestamp evaluation buffer ensuring a strict maximum of 1 frame snapshot export per second to prevent disk storage flooding and system memory leaks.
  • Asynchronous Disk Janitor Service: Runs a thread-safe background daemon task that automatically prunes and deletes localized alert snapshot files older than 24 hours to enforce hardware storage limits.
  • Persistent SQLite Analytics Ledger: Migrates runtime data from volatile RAM lists to a local relational SQLite database engine, ensuring real-time event log recovery even after full system reboots or browser refreshes.

🚀 Quick Start & Deployment

  1. Activate Environment: Ensure your isolated Python virtual environment is loaded:

    .venv\Scripts\Activate.ps1
  2. Run the Application: Start the production script from the root folder:

    python proiect_detectie/app.py
  3. Access Security Dashboard: Open Google Chrome and visit the live telemetry monitor:

    • Local Machine Endpoint: http://localhost:5000
    • Network Gateway Link: http://127.0.0.1:5000

📂 Project Architecture & Data Flow

 [ input_video.mp4 ] ──> Decoded smoothly using FFMPEG video layer.
          │
 [ YOLOv5 Inference ] ──> Generates geometric bounding boxes and raw labels.
          │
 [ Spatial Evaluator ]──> Computes Centroid: Y_center = (ymin + ymax) / 2.
          │               ↳ Triggers Alert state if Y_center breaches Tripwire.
          │
 [ SQL / Disk Engine ]──> Commits transaction to SQLite DB & exports JPG to storage.
          │
 [ Mutable Copy HUD ] ──> Duplicates array via `.copy()`, renders EN/RO overlays.
          │
 [ Multipart Stream ] ──> Encodes matrix into JPEG bytes, streams via Flask.

📊 Internal Data Structures & API Endpoints

1. Translation Dictionary Mapping

The engine translates standard COCO object classes into localized Romanian tags dynamically:

DICȚIONAR_CLASE = {
    "person": "Persoana",
    "backpack": "Rucsac_Suspect",
    "handbag": "Geanta_Abandonata",
    "suitcase": "Troller_Bagaj",
    "bicycle": "Bicicleta",
    "motorcycle": "Motocicleta",
    "car": "Vehicul_Usor",
    "truck": "Vehicul_Greu",
    "bus": "Autobuz",
    "dog": "Animal_Caine",
    "cat": "Animal_Pisica",
    "vase": "Vaza",
    "potted plant": "Planta_ghiveci",
    "umbrella": "Umbrela",
    "spoon": "Lingura",
}

2. Live Telemetry Endpoints

  • GET /video_feed: Returns a multipart MJPEG stream containing the dynamic frame buffers, bounding boxes, and the real-time SECURED / ALERT HUD overlay.
  • GET /get_alerts: Interrogates the local SQL backend and exposes a thread-safe JSON array of the last 5 registered perimeter breaches.
    [
      {
        "obiect": "Persoana",
        "timp": "20:14:32"
      }
    ]
  • POST /update_settings: Modifies application parameters at runtime via JSON payloads, adjusting the dynamic Tripwire threshold ratio (procent as a float between 0.10 and 0.90) and toggling the system alarm mute state (muted as a boolean).

About

A production-grade Perimeter Security platform using YOLOv5 and Flask. Features an AI Tripwire, async disk maintenance, and persistent SQL logging.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages