C# Class AForge.Vision.Motion.TwoFramesDifferenceDetector

Motion detector based on two continues frames difference.

The class implements the simplest motion detection algorithm, which is based on difference of two continues frames. The difference frame is thresholded and the amount of difference pixels is calculated. To suppress stand-alone noisy pixels erosion morphological operator may be applied, which is controlled by SuppressNoise property.

Although the class may be used on its own to perform motion detection, it is preferred to use it in conjunction with MotionDetector class, which provides additional features and allows to use moton post processing algorithms.

Sample usage:

// create motion detector MotionDetector detector = new MotionDetector( new TwoFramesDifferenceDetector( ), new MotionAreaHighlighting( ) ); // continuously feed video frames to motion detector while ( ... ) { // process new video frame and check motion level if ( detector.ProcessFrame( videoFrame ) > 0.02 ) { // ring alarm or do somethng else } }
Inheritance: IMotionDetector
Datei anzeigen Open project: holisticware-admin/MonoVersal.AForgeNET Class Usage Examples

Public Methods

Method Description
ProcessFrame ( UnmanagedImage videoFrame ) : void

Process new video frame.

Processes new frame from video source and detects motion in it.

Check MotionLevel property to get information about amount of motion (changes) in the processed frame.

Reset ( ) : void

Reset motion detector to initial state.

Resets internal state and variables of motion detection algorithm. Usually this is required to be done before processing new video source, but may be also done at any time to restart motion detection algorithm.

TwoFramesDifferenceDetector ( ) : System

Initializes a new instance of the TwoFramesDifferenceDetector class.

TwoFramesDifferenceDetector ( bool suppressNoise ) : System

Initializes a new instance of the TwoFramesDifferenceDetector class.

Method Details

ProcessFrame() public method

Process new video frame.

Processes new frame from video source and detects motion in it.

Check MotionLevel property to get information about amount of motion (changes) in the processed frame.

public ProcessFrame ( UnmanagedImage videoFrame ) : void
videoFrame AForge.Imaging.UnmanagedImage Video frame to process (detect motion in).
return void

Reset() public method

Reset motion detector to initial state.

Resets internal state and variables of motion detection algorithm. Usually this is required to be done before processing new video source, but may be also done at any time to restart motion detection algorithm.

public Reset ( ) : void
return void

TwoFramesDifferenceDetector() public method

Initializes a new instance of the TwoFramesDifferenceDetector class.
public TwoFramesDifferenceDetector ( ) : System
return System

TwoFramesDifferenceDetector() public method

Initializes a new instance of the TwoFramesDifferenceDetector class.
public TwoFramesDifferenceDetector ( bool suppressNoise ) : System
suppressNoise bool Suppress noise in video frames or not (see property).
return System