Skip to content

Aroomaa/Motion-Detection-OpenCV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Intrusion Detection in Restreicted Area

Introduction

This project implements Restricted Area Intrusion Detection System using OpenCV and its different functions. In this proect, user can manually select the region of interest i.e. restricted area. Once the region is selected, the system continuously monitors motion within that region and triggers an alert whenever any intrusion is detected. It also notes the time when intrusion is detected. The project is kept simple so it remains a begginer friendly code.

Features

  • Manual ROI Selection, drawing your own desirable restricted area on the video frame using mouse
  • Real-time intrusion detection using:
    • Backgrounf subtractor MOG2
    • Morphological filtering
    • Motion masking with ROI
  • Automatic logging of intrusion by:
    • Saving the frame where intrusion occured
    • Writing timestamps
  • Clean visual outputs at different steps for better understanding of code
    • Processing steps like raw masking, blurring, opened/closed mask
    • ROI mask status
    • Intrusion status on video

alt text

Working

  1. Load the firt frame of tthe video
  2. Select the ROI by clicking and dragging left mouse button. Press 's' on the keyboard to save the coordinates. Press 'r' to redraw.
  3. For every frame:
    • Convert to grayscale
    • Apply MOG2 background subtraction
    • Apply blur + morphological filtering
    • Mask the ROI region
    • Count motion pixels inside the ROI
  4. If motion exceeds the threshold value then intrusion is detected
  5. Saves the frame and logs timestamps
  6. Display the visuals of
    • Processing steps
    • ROI Masks
    • Original video with detection

Controls

  • Click & Drag: Draw ROI
  • Press S: Save ROI
  • Press R: Redraw ROI
  • Press Q: Quit

Libraries

pip install opencv-python
pip install numpy
pip install matplotlib

Important

  • No dataset is provided. Users can use any CCTV style footage, webcam footage, screen recording
  • The system masks shadows during background subtraction, and the motion-pixel threshold is tuned so shadows are not treated as intrusions
  • Threshold for motion pixels can be customised or adusted depending on lighting and movement of your video

About

Real-time restricted area surveillance using OpenCV. Manual ROI selection, MOG2 background subtraction, motion alerts and automatics timestamp logging. Beginner-friendly.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors