Skip to content

mertCukadar/Lightweight-Adaptive-Motion-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lightweight Adaptive Motion Detection Without External Libraries

1. Introduction

This study investigates the possibility of detecting motion in a video stream without relying on complex computer vision libraries. The core objective is to determine if a mathematically derived, adaptive equation can reliably detect movement. The dynamics of managing this process in real-time and the research findings regarding efficiency will be discussed in the conclusion.

2. Algorithmic Workflow & Methodology

The proposed algorithm follows a minimalist and computationally efficient path:

  • Image Acquisition: Capturing raw frames from the camera sensor.
  • Downscaling: Resizing the image to a lower resolution (e.g., $150 \times 100$).

Observation: Raw high-resolution frames exhibit significant sensor noise. Downscaling acts as a spatial low-pass filter, reducing noise and improving data quality for thresholding.

scaled_img_hist

scaled_img_hist

  • Grayscale Conversion: Reducing the 3-channel (RGB) data to a single intensity channel to simplify calculations.
  • Mean Pixel Calculation: Calculating the average brightness of the current frame ($\mu_{current}$).
  • Frame Averaging: Computing the historical average of the last $n$ frames (window size $= 255$) to establish a dynamic baseline:

$$\bar{\mu}_{window} = \frac{1}{n} \sum_{i=1}^{n} \mu_i$$

3. Mathematical Model & Normalization

The system detects motion by analyzing the absolute difference between the current frame's mean and the historical window mean:

$$\Delta\mu = |\mu_{current} - \bar{\mu}_{window}|$$

To handle varying environments, a 0-1 Normalization is applied based on the observed maximum difference ($\Delta\mu_{max}$):

$$\text{Normalized } \Delta\mu = \frac{\Delta\mu}{\Delta\mu_{max}}$$

3.1. Adaptive Decay Mechanism

A critical challenge is the calibration of $\Delta\mu_{max}$. If left static, the system loses sensitivity over time or reacts poorly to light changes. We implemented a Decay Method to allow the system to "forget" old peaks and adapt to the current environment:

$$\Delta\mu_{max, t} = \max(\Delta\mu_{max, t-1} \cdot 0.95, 2.0)$$

  • Decay Rate (0.95): Decreases the maximum threshold by $5%$ per frame.
  • Noise Floor (2.0): Ensures the threshold never drops into the sensor noise range, preventing false positives in static scenes.

4. Results & Discussion

motion_false

motiom_true

The implementation demonstrates that a library-free, purely mathematical approach is highly effective for motion detection.

  • Noise Management: Downscaling significantly improved the Signal-to-Noise Ratio (SNR) and reduced computational overhead, making it suitable for edge devices.
  • Environmental Adaptation: The decay mechanism successfully managed changing light conditions. The $2.0$ unit noise floor was essential in maintaining stability in low-light or static environments.
  • Calibration: The "cold start" period, where the sliding window is initially filled, was mitigated by the rapid adaptation of the $\Delta\mu_{max}$ value.

Conclusion

The developed system successfully identifies motion by leveraging pixel intensity variations. While the current model uses arithmetic means, future iterations could incorporate Standard Deviation ($\sigma$) for a Z-Score based analysis to further distinguish subtle movements from stochastic sensor noise.

About

Lightweight motion detection via pixel intensity analysis and temporal averaging. Features an adaptive decay-based normalization to handle dynamic lighting conditions without external CV libraries.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages