Enum MotionDetectorType
- Assembly
- VisioForge.Core.dll
Specifies the algorithm used for detecting motion in video frames by analyzing pixel differences over time.
public enum MotionDetectorTypeFields
CustomFrameDifference = 0-
Detects motion by comparing each frame against a predefined reference (background) frame.
This detector compares the current frame with a static reference frame that represents the scene without any moving objects. Motion is detected wherever the current frame differs significantly from the reference.
Characteristics: - Requires manual or automatic capture of a clean background frame - Excellent for controlled environments with stable backgrounds - Does not adapt to gradual scene changes (lighting, shadows) - Very sensitive to camera movement or vibration - Low computational requirements
Best suited for: - Indoor surveillance with controlled lighting - Production line monitoring - Museum or gallery security - Detecting intrusions in normally empty areas - Short-term monitoring sessions
Limitations: - Background must be updated if scene changes permanently - Ineffective for outdoor scenes with changing conditions - Cannot handle moved furniture or parked vehicles
SimpleBackgroundModeling = 1-
Detects motion using an adaptive background model that updates over time.
This detector maintains a statistical model of the background that adapts to gradual changes in the scene. It can distinguish between temporary motion and permanent scene changes, updating its background model accordingly.
Characteristics: - Automatically adapts to lighting changes (sunrise/sunset) - Handles shadows and reflections better than frame difference - Can learn to ignore repetitive motion (trees, flags) - Moderate computational requirements - Configurable learning rate for background updates
Best suited for: - Long-term surveillance applications - Outdoor monitoring with changing conditions - Traffic monitoring systems - Parking lot surveillance - Perimeter security
Advanced features: - Gradual incorporation of stationary objects into background - Resistance to sudden illumination changes - Shadow suppression capabilities - Multi-modal background representation
Note: The adaptation rate can typically be configured to balance between quick adaptation to scene changes and resistance to incorporating moving objects into the background model.
TwoFramesDifference = 2-
Detects motion by comparing consecutive frames in the video stream.
This is the simplest and fastest motion detection method, comparing each frame only with the immediately preceding frame. Any significant difference between consecutive frames is considered motion.
Characteristics: - Fastest processing speed, minimal CPU usage - No initialization or training required - Works immediately on any video stream - Detects all types of motion equally - Handles camera movement naturally
Best suited for: - Real-time applications with high frame rates - Mobile or embedded systems with limited resources - PTZ (Pan-Tilt-Zoom) camera systems - Drone or vehicle-mounted cameras - Initial motion detection before detailed analysis
Limitations: - Cannot distinguish between object motion and camera motion - Sensitive to noise and compression artifacts - May miss slow-moving objects - No concept of background vs. foreground - Detects changes in lighting as motion
Performance tips: - Works best with stable, high-quality video sources - May require higher threshold values to reduce noise - Can be combined with other techniques for validation
Examples
// Configure for surveillance with adaptive background
var surveillanceSettings = new MotionDetectionExSettings
{
DetectorType = MotionDetectorType.SimpleBackgroundModeling,
DifferenceThreshold = 20,
SuppressNoise = true
};
// Configure for detecting motion against a reference image
var referenceSettings = new MotionDetectionExSettings
{
DetectorType = MotionDetectorType.CustomFrameDifference,
DifferenceThreshold = 15
};
// Set the reference frame
motionDetector.SetReferenceFrame(backgroundImage);
// Configure for quick motion detection
var quickSettings = new MotionDetectionExSettings
{
DetectorType = MotionDetectorType.TwoFramesDifference,
DifferenceThreshold = 10
};
Remarks
Motion detection algorithms form the foundation of many video analysis applications including security surveillance, traffic monitoring, and activity analysis. Each algorithm has different characteristics in terms of accuracy, performance, and suitability for various scenarios.
The choice of detector affects: - Sensitivity to different types of motion - Handling of lighting changes and shadows - Computational performance requirements - Adaptation to scene changes - False positive rates
All detectors work in conjunction with the VisioForge.Core.Types.VideoProcessing.MotionDetectionExSettings.DifferenceThreshold to determine what constitutes significant motion versus noise or minor changes.