This repository contains the implementation of a Real-Time Object Tracking system using Gaussian Mixture Models (GMM). The project focuses on the application of GMM for background subtraction and motion analysis in video streams, particularly useful in scenarios like traffic surveillance.
The project employs Gaussian Mixture Models to differentiate between the background and foreground in video frames. It is particularly adept at tracking objects in real-time within a fixed camera view, such as monitoring traffic through a surveillance camera.
The algorithm was tested on a 30-second traffic IP camera video from YouTube. This provided a realistic and challenging environment for object tracking.
- Video Processing: The input video is processed using OpenCV to extract individual frames.
- Gaussian Mixture Modeling: Each pixel value across all frames is modeled as a mixture of two Gaussians, representing the background and foreground.
- Background Construction: The Gaussian with more weight and less standard deviation is used for constructing the background.
- Object Tracking: Objects are tracked by subtracting the background from each frame.
- Initialization: Mean and variance values for both Gaussians are initialized.
- Likelihood Calculation: Likelihood of each observation is calculated using initial mean and variance values.
- Probability Density Function: Calculate PDF for both Gaussian clusters.
- Posterior Probability: Using Bayes Theorem, we calculate the posterior probability for each Gaussian.
- Parameter Re-estimation: The mean, variance, and weights of both Gaussians are iteratively updated until convergence.
- The implementation focuses more on demonstrating the concept rather than optimization for time complexity.
- The approach may struggle with foreground objects that are present for an extended duration.
The algorithm successfully segments moving objects from the background, as evidenced by the output frames and the final video demonstrating the moving object detection.
The algorithm's performance was measured against OpenCV's BackgroundSubtractorMOG2 function using Mean Squared Error (MSE). The results show the effectiveness of the GMM approach in real-time object tracking.
- Gaussian Mixture Models Tutorial
- [Research Papers and Articles](URLs to the relevant papers and articles)
Instructions on how to run and use the code can be found in the accompanying Jupyter notebook (rtod_gmm.ipynb
).
Contributions to this project are welcome. Please refer to the contributing guidelines for more information.
This project is open-source and available under the MIT License.