Skip to content

MarwenKR/Event_Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EPT Surveillance Video - Events Detection

A real-time video surveillance system that detects intrusions in user-defined protected zones using the YOLO (You Only Look Once) object detection model via Darkflow. Built with Python, OpenCV, and TensorFlow.


Overview

This project was developed at EPT (Ecole Polytechnique de Tunisie) as part of an academic project on event detection in video streams. The system captures a live webcam feed, allows the user to define a "Protected Zone" on screen, and triggers alerts whenever a person is detected inside that zone during a configurable time window.

Key Features

  • Real-time person detection using the Tiny-YOLO-VOC pre-trained model
  • Interactive protected zone selection - draw a rectangle on the video feed to define the monitored area
  • Time-based monitoring - configure start/end times for zone protection via parameters.txt
  • Intrusion logging - all detections are recorded with timestamps in logfile.log
  • Video recording - detected events are saved to an output video file
  • Configurable detection labels - specify which objects to detect via labels_det.txt

Demo

1. Launching the Application

Run the detection script with the YOLO model and weights:

python projet.py --model ../cfg/tiny-yolo-voc.cfg --load ../bin/tiny-yolo-voc.weights -sz 750

Run command

2. Loading the YOLO Model

The system loads the Tiny-YOLO-VOC model and builds the neural network architecture:

Loading model

Model architecture layers

3. Live Video Stream

Once the model is loaded, the webcam feed starts with a real-time timestamp overlay:

Video stream started

4. Defining the Protected Zone

Press i to enter zone selection mode, then draw a rectangle with the mouse to define the area to monitor. Press Enter or Space to confirm, or c to select the whole frame:

Selecting ROI zone

ROI selection confirmation

5. Intrusion Detection & Alert

When a person enters the protected zone during the configured time window, the system displays an "Alert !!!" warning and logs the event:

Protected zone defined

Person detected - intrusion alert

6. Logging & Configuration Files

parameters.txt - Defines the time window for zone monitoring:

Parameters file

logfile.log - Records every intrusion event with date and time:

Log file output

labels_det.txt - Lists the object labels to detect (e.g., "person"):

Labels file

7. Final Summary

After pressing q to quit, the system displays elapsed time, FPS, and saves the recorded video:

Final output summary


Project Structure

Projet events detection/
├── README.md                  # This file
├── src/                       # Source code
│   ├── projet.py              # Main detection script
│   ├── guide.md               # Usage guide
│   ├── labels_det.txt         # Labels to detect (e.g., "person")
│   ├── parameters.txt         # Time window configuration
│   └── logfile.log            # Detection log output
├── docs/                      # Documentation
│   ├── Sujet Projet.docx      # Project brief / subject
│   ├── Les étapes du projet.docx  # Project milestones
│   ├── plan rapport.docx      # Report outline
│   ├── Video Stream Analytics Using OpenCV.docx  # OpenCV analytics guide
│   └── references/            # Research papers & bibliography
│       ├── yolo.pdf
│       ├── 2010CLF22089_-_LUVISON.pdf
│       ├── Human-detection-from-images-and-videos-*.pdf
│       ├── Combining-motion-and-appearance-cues-*.pdf
│       └── ... (additional pattern recognition papers)
├── images/                    # Demo screenshots
│   ├── 01_run_command.png
│   ├── 02_loading_model.png
│   ├── ...
│   └── 13_final_output_summary.png
└── output/                    # Recorded output videos
    └── video.avi

Dependencies

Installation

  1. Clone or download this repository.

  2. Install Darkflow by following the instructions at thtrieu/darkflow.

  3. Download the Tiny-YOLO-VOC weights and config files and place them in the appropriate directories (bin/ and cfg/).

  4. Install Python dependencies:

    pip install tensorflow==1.x numpy opencv-python imutils

Usage

  1. Configure detection labels - Edit src/labels_det.txt to list the objects you want to detect (one per line). Default is person.

  2. Configure time window - Edit src/parameters.txt with the start and end datetime for zone protection, using the format YYYY-MM-DD HH:MM:SS.

  3. Run the program:

    cd src/
    python projet.py --model <path_to_model.cfg> --load <path_to_weights>
  4. Interactive controls:

    • Press i to draw the protected zone
    • Press Enter/Space to confirm the zone selection
    • Press c to select the entire frame as the zone
    • Press q to quit

Command-Line Arguments

Argument Short Default Description
--model -m required Path to YOLO model config file
--load -l required Path to YOLO weights file
--confidence -conf 0.2 Minimum detection confidence
--person -p 0.3 Person detection threshold
--seize -sz 650 Window display size (px)
--fps -f 5 Output video FPS
--save -s video.avi Output video file path
--codec -cod XVID Output video codec

How It Works

The system uses a Tiny-YOLO-VOC model for real-time object detection on each video frame. When the user defines a protected zone (via an interactive ROI selector), the program computes the overlap ratio (Intersection over Union) between each detected bounding box and the protected zone. If the overlap exceeds a threshold (5%) and the current time falls within the configured monitoring window, an intrusion alert is triggered, displayed on screen, and logged to logfile.log.


Author

Marwen Kraiem - EPT (Ecole Polytechnique de Tunisie), 2018


References

Research papers used in this project are available in the docs/references/ folder, covering topics such as human detection, anomaly detection, pattern recognition, and the YOLO architecture.

About

A real-time video surveillance system that detects intrusions in user-defined protected zones using the **YOLO** (You Only Look Once) object detection model via Darkflow.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages