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.
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.
- 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:
The system detects motion by analyzing the absolute difference between the current frame's mean and the historical window mean:
To handle varying environments, a 0-1 Normalization is applied based on the observed maximum difference (
A critical challenge is the calibration of
-
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.
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.
The developed system successfully identifies motion by leveraging pixel intensity variations. While the current model uses arithmetic means, future iterations could incorporate Standard Deviation (