Motion detection is a critical capability in fields such as surveillance, robotics, and computer vision. It involves identifying moving objects in video sequences and serves as the foundation for many advanced applications, from geospatial analysis to autonomous systems.
This project explores various motion detection methods, including:
- Frame Difference
- Background Subtraction
- Optical Flow (Sparse and Dense)
- Background Subtraction combined with Object Detection (MOG + YOLO)
The goal is to evaluate their strengths, limitations, and real-world applications while showcasing their implementation and comparative analysis.
- Compares consecutive video frames pixel by pixel to identify changes.
- Strengths: Simple and computationally efficient.
- Weaknesses: Sensitive to noise, struggles with complex backgrounds.
- Models the static background scene to identify moving objects.
- Techniques include:
- Mixture of Gaussians (MOG)
- K-Nearest Neighbors (KNN)
- Strengths: Effective in dynamic environments.
- Weaknesses: Sensitive to shadows and lighting changes.
- Computes motion vectors for pixels between consecutive frames.
- Sparse Optical Flow: Focuses on key points (e.g., corners, edges).
- Dense Optical Flow: Provides motion vectors for every pixel.
- Strengths: Detailed motion understanding.
- Weaknesses: High computational complexity, sensitive to noise.
- Combines MOG background subtraction with YOLOv8 object detection.
- Detects and classifies moving objects.
- Strengths: High accuracy, robust against complex scenarios.
- Weaknesses: Computationally intensive, challenges with fast motion.
| Method | Advantages | Limitations |
|---|---|---|
| Frame Differencing | Simple and efficient | Sensitive to noise, poor with complex scenes |
| Background Subtraction | Robust for dynamic environments | Requires accurate background modeling |
| Optical Flow | Comprehensive motion analysis | Computationally expensive, sensitive to noise |
| MOG + YOLO | High accuracy, robust classification | Resource-intensive, struggles with rapid motion |
- Frame Differencing: Effective for simple, static backgrounds but prone to errors in complex scenes.
- Background Subtraction: Offers improved accuracy but detects shadows and lighting changes as motion.
- Optical Flow:
- Sparse: Limited to key points; suitable for coarse analysis.
- Dense: Highly detailed but requires significant computational resources.
- MOG + YOLO: Best performance in detecting and classifying moving objects; however, requires GPU acceleration for real-time applications.
- Python 3.x
- OpenCV (with CUDA support for Dense Optical Flow)
- YOLOv8 by Ultralytics
- Pytorch with CUDA support
-
Clone this repository:
git clone https://github.com/OmarAlmusa/motion-detection-app-python.git cd motion-detection -
Install the required libraries:
pip install -r requirements.txt
-
Run the program as following:
python main_interface.py
This project is based on extensive research and implementation of algorithms and techniques documented in:
- OpenCV Documentation
- Research papers on motion detection
- NVIDIA VPI Documentation
- Ultralytics YOLOv8
- Customtkinter
More information about the project can be found in docx file provided in the repo.