C# Класс 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 } }
Наследование: IMotionDetector
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Описание методов

ProcessFrame() публичный Метод

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).
Результат void

Reset() публичный Метод

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
Результат void

TwoFramesDifferenceDetector() публичный Метод

Initializes a new instance of the TwoFramesDifferenceDetector class.
public TwoFramesDifferenceDetector ( ) : System
Результат System

TwoFramesDifferenceDetector() публичный Метод

Initializes a new instance of the TwoFramesDifferenceDetector class.
public TwoFramesDifferenceDetector ( bool suppressNoise ) : System
suppressNoise bool Suppress noise in video frames or not (see property).
Результат System