Skip to content

Real-time drone surveillance system utilizing YOLOv8 for motion/object detection with a GenAI-powered Natural Language Query (NLQ) interface for auditing SQLite security logs

License

Notifications You must be signed in to change notification settings

KunalKhadgi/drone_based_security_

Repository files navigation

Object Detection and Motion Analysis with YOLOv8

Demo Link

Find the demo link here

Overview

This project implements object detection and motion analysis using the YOLOv8 model. It processes video files, images, and webcam streams to identify and track objects. The detections are logged into a SQLite database for further analysis.

Features

  • YOLOv8-based Object Detection: Detects and tracks objects in videos, images, and real-time webcam streams.
  • Motion Analysis: Analyzes object movement across frames.
  • Database Logging: Logs detected objects with timestamps and context.
  • Video and Webcam Processing: Supports both file-based and real-time detection.
  • Entry Zone Logging: Detects and logs objects entering specific zones.
  • Database querying: Uses flash-2.0 for qureying db in nlp

Project Structure

|-- main.py                 # Entry point for running video and webcam processing
|-- object_detection.py      # Handles YOLOv8-based detection and tracking
|-- motion_detection.py      # Motion analysis and logging
|-- log_query.py            # Queries and retrieves logs from SQLite database
|-- entry_zone_logger.py     # Logs objects entering a defined entry zone
|-- yolov8n-pose.pt          # Pre-trained YOLOv8 model files 
|-- detection_log.db        # SQLite database storing detected objects
|-- detection_log.txt       # Log file storing object detections
|-- .env                    # Environment variables configuration

Installation

Prerequisites

Ensure you have Python 3.8+ installed and set up a virtual environment:

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt

Required Dependencies

Install necessary Python libraries:

pip install ultralytics numpy opencv-python sqlite3 python-dotenv

Usage

Processing a Video File

  • Open main.py
  • set value of mode to either of image, video or webcam
  • if image or video provide the file path in 'path' variable
python main.py

Processing a Webcam Stream

python main.py

Setting Up Log Query (.env file)

  1. Create a .env file in the root directory and enter:
API_KEY=your_google_genai_api_key

Querying Logs

To view logged detections from the database, run:

python log_query.py

Flow of the Project

  1. Loading the Model
    • YOLOv8 model is loaded from the models/ directory.
  2. Processing Video/Webcam
    • Reads frames from a video file or webcam.
    • Runs YOLOv8 detection on each frame.
  3. Tracking Objects
    • Assigns unique IDs to detected objects.
    • Tracks object movement across frames.
  4. Motion Analysis
    • Compares positions between frames.
    • Identifies entry/exit events.
  5. Entry Zone Detection (In different folder/Independent flow but same logic 1-4)
    • Monitors and logs objects entering defined zones.
    • Stores entry data in detection_log.db.
  6. Logging Detections
    • Stores detected objects in detection_log.db.
    • Logs detection events in detection_log.txt.

This README provides a structured guide for setting up and running the project.

About

Real-time drone surveillance system utilizing YOLOv8 for motion/object detection with a GenAI-powered Natural Language Query (NLQ) interface for auditing SQLite security logs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages