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.
- 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
- Load the firt frame of tthe video
- Select the ROI by clicking and dragging left mouse button. Press 's' on the keyboard to save the coordinates. Press 'r' to redraw.
- For every frame:
- Convert to grayscale
- Apply MOG2 background subtraction
- Apply blur + morphological filtering
- Mask the ROI region
- Count motion pixels inside the ROI
- If motion exceeds the threshold value then intrusion is detected
- Saves the frame and logs timestamps
- Display the visuals of
- Processing steps
- ROI Masks
- Original video with detection
- Click & Drag: Draw ROI
- Press S: Save ROI
- Press R: Redraw ROI
- Press Q: Quit
pip install opencv-python
pip install numpy
pip install matplotlib
- 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
