SR Logo/AI Engineering
Computer VisionPRODUCTION

Dual-EMA Real-Time Perimeter Intrusion Detection Pipeline

Classical computer vision perimeter security pipeline utilizing dual-EMA background subtraction, contour tracking, and global lighting change suppression on live CCTV feeds.

CategoryComputer Vision
Statusproduction System
Core Tooling
OpenCVClassical Computer VisionDual-EMAPythonFastAPICCTV Streams

01. Problem & Operational Context

Perimeter security CCTV feeds experience continuous false alarms triggered by sudden cloud cover, wind-blown foliage, shadows, and camera auto-exposure adjustments when using standard motion detection.

02. Technical Approach

Designed a resilient classical CV intrusion and unattended-object detection pipeline utilizing dual Exponential Moving Average (EMA) background models with diff-mask visualization and global illumination change suppression.

03. System Architecture & Pipeline

End-to-End System Pipeline & Computation Flow

Two-speed background modeling framework separating fast illumination fluctuations from slow physical scene modifications.

STEP 01OpenCV / NumPy
Stream Preprocessing & Grayscale Normalization

CCTV frame decimation, Gaussian smoothing, and local contrast normalization.

STEP 02Dual-EMA Algorithm
Dual-EMA Background Modeling

Simultaneous fast and slow background update rate modeling to distinguish moving intrusions from stationary objects.

STEP 03OpenCV Morphological Ops
Global Lighting Shift Suppression

Histogram variance analysis detecting whole-frame illumination shifts and suppressing false alarm triggers.

STEP 04Python / FastAPI
Contour Analysis & Intrusion Alerting

Connected component contour extraction, spatial perimeter boundary checking, and diff-mask generation.

04. Key Implementation Details

  • Engineered a dual Exponential Moving Average background subtraction model maintaining dual temporal reference frames $(alpha_{ ext{fast}}, alpha_{ ext{slow}})$.
  • Developed global illumination change detection to suppress false alarms during sudden sunlight/cloud transitions.
  • Created diff-mask visualization pipeline for operator surveillance review on live CCTV channels.
  • Constructed contour tracking logic calculating bounding boxes and persistence metrics for unattended objects.

05. Architectural Tradeoffs & Decisions

Decision: Selected classical Dual-EMA computer vision pipeline over heavy neural networks for 24/7 continuous CCTV monitoring.
Justification

Runs with near-zero CPU/GPU utilization across dozens of parallel video streams simultaneously while maintaining deterministic response.

Alternative Considered

Heavy deep learning video segmentation models requiring dedicated high-end GPUs per stream.

06. Engineering Challenges & Failures

Challenge: Rapid sunlight shifts triggering massive false-positive motion masks across the entire camera view.
Solution: Incorporated whole-frame delta thresholding that identifies global illumination changes and temporarily adapts background weights without firing perimeter alerts.
Challenge: Distinguishing legitimate moving intruders from permanently dropped unattended packages.
Solution: Leveraged dual-EMA differential states where stationary objects transition from fast model to slow model over defined temporal thresholds.

07. Evaluation & Observations

Evaluation Methodology:

Benchmarked on operational CCTV perimeter security streams under varying weather, cloud cover, and night-vision modes.

Key Empirical Finding:

Dual-EMA temporal separation accurately flagged unattended objects while ignoring transient environmental noise.

Verified Artifacts
architectureDual-EMA Background Pipeline

Mathematical flow of fast/slow exponential moving averages and global lighting suppression filter.