FaceGuard
FaceGuard automatically detects and blurs faces in video frames using state-of-the-art computer vision models. It's designed for privacy-conscious applications that need real-time face anonymization with configurable detection sensitivity and blur intensity.
How It WorksDirect link to How It Works
The filter uses a multi-stage pipeline:
- Face Detection: Uses OpenCV's YuNet model to detect faces in each frame
- Confidence Filtering: Only processes faces above the confidence threshold
- Blur Application: Applies Gaussian blur to detected face regions
- Metadata Extraction: Optionally includes face coordinates and detection confidence
- Output Generation: Returns the processed frame with optional upstream data forwarding
FeaturesDirect link to Features
Advanced Face DetectionDirect link to advanced-face-detection
- YuNet Model: Uses OpenCV's state-of-the-art YuNet face detector
- Configurable Sensitivity: Adjust detection confidence threshold (0.0-1.0)
- Real-time Processing: Optimized for live video streams
- Multiple Face Support: Detects and blurs multiple faces per frame
Flexible ConfigurationDirect link to flexible-configuration
- Environment Variable Driven: No command-line arguments needed
- Dynamic Output Naming: Automatically generates descriptive output filenames
- Debug Mode: Optional logging for development and troubleshooting
- Upstream Data Forwarding: Passes through data from upstream filters
Rich Metadata OutputDirect link to rich-metadata-output
- Face Coordinates: Bounding box and center coordinates for each detected face
- Confidence Scores: Detection confidence for each face
- Face Count: Total number of faces detected per frame
- Detection Details: Structured data for downstream processing
Configuration OptionsDirect link to Configuration Options
Core Detection SettingsDirect link to Core Detection Settings
| Parameter | Type | Default | Description |
|---|---|---|---|
FILTER_DETECTOR_NAME | string | "yunet" | Face detector type (yunet, haar, dnn) |
FILTER_DETECTION_CONFIDENCE_THRESHOLD | float | 0.25 | Minimum confidence for face detection (0.0-1.0) |
FILTER_BLURRER_NAME | string | "gaussian" | Blur algorithm (gaussian, box, median) |
FILTER_BLUR_STRENGTH | float | 1.0 | Blur intensity (higher = more blur) |
Model ConfigurationDirect link to Model Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
FILTER_MODEL_ARTIFACTORY_URL | string | OpenCV Zoo URL | Base URL for model download |
FILTER_MODEL_ARTIFACT_NAME | string | "face_detection_yunet_2023mar.onnx" | Model filename |
Output and DebuggingDirect link to Output and Debugging
| Parameter | Type | Default | Description |
|---|---|---|---|
FILTER_DEBUG | boolean | false | Enable debug logging |
FILTER_FORWARD_UPSTREAM_DATA | boolean | true | Forward data from upstream filters |
FILTER_INCLUDE_FACE_COORDINATES | boolean | true | Include face coordinates in frame data |
Usage ExamplesDirect link to Usage Examples
Basic UsageDirect link to Basic Usage
# Run with default settings
python scripts/filter_usage.py
Custom Video InputDirect link to Custom Video Input
# Process a specific video file
VIDEO_INPUT="./data/surveillance_footage.mp4" python scripts/filter_usage.py
High Sensitivity DetectionDirect link to High Sensitivity Detection
# Detect more faces (lower confidence threshold)
FILTER_DETECTION_CONFIDENCE_THRESHOLD=0.1 python scripts/filter_usage.py
Strong Blur EffectDirect link to Strong Blur Effect
# Apply heavy blurring
FILTER_BLUR_STRENGTH=3.0 python scripts/filter_usage.py
Debug ModeDirect link to Debug Mode
# Enable debug logging
FILTER_DEBUG=true python scripts/filter_usage.py
Output Data StructureDirect link to Output Data Structure
The filter enriches each frame with detailed face detection metadata:
{
"faces_detected": 2,
"face_coordinates": [
{
"bbox": [100, 50, 80, 100],
"confidence": 0.95
}
],
"face_details": [
{
"face_id": 0,
"bounding_box": {
"x": 100, "y": 50,
"width": 80, "height": 100
},
"center": {
"x": 140, "y": 100
},
"confidence": 0.95
}
]
}
When to UseDirect link to When to Use
Perfect For:Direct link to perfect-for
- Surveillance Systems: Anonymize faces in security footage
- Retail Analytics: Protect customer privacy in store monitoring
- Live Streaming: Real-time face blurring for privacy compliance
- Social Media: Automatic face anonymization for content sharing
- Research: Privacy-preserving video analysis
Consider Alternatives For:Direct link to consider-alternatives-for
- High-Resolution Processing: Very large images may impact performance
- Batch Processing: Designed for real-time streams, not batch operations
- Custom Detection: Limited to face detection (not objects or other features)
Performance TuningDirect link to Performance Tuning
Detection SensitivityDirect link to Detection Sensitivity
- Lower threshold (0.1-0.2): More faces detected, higher false positives
- Higher threshold (0.5-0.8): Fewer faces detected, higher precision
- Default (0.25): Balanced approach for most use cases
Blur StrengthDirect link to Blur Strength
- Light blur (0.5-1.0): Faces still somewhat recognizable
- Medium blur (1.0-2.0): Good privacy protection (default)
- Heavy blur (2.0+): Complete anonymization
Pro Tip
For best results, test different confidence thresholds with your specific video content to find the optimal balance between detection accuracy and false positives.
Important
Ensure the model file is publicly accessible or pre-downloaded for edge deployments. The filter will automatically download models from the configured URL on first run.