Overview
TheEVMProcessor class implements the core Eulerian Video Magnification algorithm with an optimized dual-band processing approach. It builds Laplacian pyramids once and processes both heart rate and respiratory rate frequency bands simultaneously.
EVMProcessor Class
Constructor
Parameters
Number of Laplacian pyramid levels to build. Default from
config.LEVELS_RPI.- Higher levels capture finer spatial details
- Typical range: 2-4 levels
- Level 3 optimal for heart rate
- Level 2 optimal for respiratory rate
Amplification factor for heart rate frequency band. Default from
config.ALPHA_HR.- Controls signal magnification strength
- Higher values = stronger amplification
- Too high may introduce noise
- Typical range: 20-50
Amplification factor for respiratory rate frequency band. Default from
config.ALPHA_RR.- Respiratory signals are weaker and need higher amplification
- Typical range: 40-100
process_dual_band Method
Single-pass EVM pipeline that extracts two temporal signals simultaneously.Parameters
List of ROI video frames in BGR format. Minimum 30 frames required for accurate temporal analysis.
Returns
Temporal signal for heart rate analysis. 1D array of magnified pixel intensities from the green channel.
Returns
None if processing fails.Temporal signal for respiratory rate analysis. 1D array of magnified pixel intensities averaged across channels.
Returns
None if processing fails.Processing Pipeline
The dual-band approach implements a 6-step optimized pipeline:Step 1: Build Laplacian Pyramids (Single Pass)
Key Optimization: Pyramids are built only once, then different levels are extracted for each frequency band. Traditional approaches build pyramids twice.
Step 2: Select Optimal Pyramid Levels
- Heart Rate: Uses level 3 for higher spatial frequencies
- Respiratory Rate: Uses level 2 for lower spatial frequencies
Step 3: Extract Tensor Data
(T, H, W, C) where:
T= number of framesH= height at pyramid levelW= width at pyramid levelC= color channels (3 for BGR)
Step 4: Temporal Bandpass Filtering
Step 5: Signal Amplification
Step 6: Extract Temporal Signals
Architecture Diagram
Usage Example
Dual-Band Optimization Benefits
Performance
- 50-60% faster than traditional approach
- Single pyramid build instead of two
- Parallel signal extraction
Accuracy
- Maintains true EVM accuracy
- Separate optimization per frequency band
- No signal interference between bands
Implementation Details
Why Different Pyramid Levels?
Different vital signs have different spatial characteristics:- Heart Rate (Level 3): Pulse signals manifest as subtle color changes in capillaries, requiring higher spatial resolution
- Respiratory Rate (Level 2): Breathing causes larger-scale motion, captured better at lower spatial resolution
Why Different Amplification Factors?
Signal strengths vary by vital sign:- Heart Rate (alpha=30): Pulse signals are relatively strong in facial videos
- Respiratory Rate (alpha=50): Breathing signals are weaker and need stronger amplification
Green Channel for Heart Rate
The green channel provides the best signal-to-noise ratio for pulse detection because:- Hemoglobin absorbs green light more effectively
- Less sensitive to melanin variations
- Reduced motion artifacts
Error Handling
The method handles errors gracefully:- Insufficient Frames: Returns
(None, None)if fewer than 30 frames - Invalid Input: Returns
(None, None)for non-list/array inputs - Pyramid Failures: Continues with available pyramid levels
Related Functions
- build_video_pyramid_stack - Builds Laplacian pyramids
- extract_pyramid_level - Extracts specific pyramid level
- apply_temporal_bandpass - Temporal filtering
- extract_temporal_signal - Signal extraction