C# Класс Accord.Vision.Motion.MotionDetector

Motion detection wrapper class, which performs motion detection and processing.

The class serves as a wrapper class for motion detection and motion processing algorithms, allowing to call them with single call. Unlike motion detection and motion processing interfaces, the class also provides additional methods for convenience, so the algorithms could be applied not only to Accord.Imaging.UnmanagedImage, but to .NET's Bitmap class as well.

In addition to wrapping of motion detection and processing algorthms, the class provides some additional functionality. Using MotionZones property it is possible to specify set of rectangular zones to observe - only motion in these zones is counted and post procesed.

Sample usage:

// create motion detector MotionDetector detector = new MotionDetector( new SimpleBackgroundModelingDetector( ), 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 } }
Показать файл Открыть проект

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

Метод Описание
MotionDetector ( IMotionDetector detector ) : System

Initializes a new instance of the MotionDetector class.

MotionDetector ( IMotionDetector detector, IMotionProcessing processor ) : System

Initializes a new instance of the MotionDetector class.

ProcessFrame ( Bitmap videoFrame ) : float

Process new video frame.

See ProcessFrame(UnmanagedImage) for additional details.

ProcessFrame ( BitmapData videoFrame ) : float

Process new video frame.

See ProcessFrame(UnmanagedImage) for additional details.

ProcessFrame ( UnmanagedImage videoFrame ) : float

Process new video frame.

The method first of all applies motion detection algorithm to the specified video frame to calculate motion level and motion frame. After this it applies motion processing algorithm (if it was set) to do further post processing, like highlighting motion areas, counting moving objects, etc.

In the case if MotionZones property is set, this method will perform motion filtering right after motion algorithm is done and before passing motion frame to motion processing algorithm. The method does filtering right on the motion frame, which is produced by motion detection algorithm. At the same time the method recalculates motion level and returns new value, which takes motion zones into account (but the new value is not set back to motion detection algorithm' IMotionDetector.MotionLevel property).

Reset ( ) : void

Reset motion detector to initial state.

The method resets motion detection and motion processing algotithms by calling their IMotionDetector.Reset and IMotionProcessing.Reset methods.

Приватные методы

Метод Описание
CreateMotionZonesFrame ( ) : void

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

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

Initializes a new instance of the MotionDetector class.
public MotionDetector ( IMotionDetector detector ) : System
detector IMotionDetector Motion detection algorithm to apply to each video frame.
Результат System

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

Initializes a new instance of the MotionDetector class.
public MotionDetector ( IMotionDetector detector, IMotionProcessing processor ) : System
detector IMotionDetector Motion detection algorithm to apply to each video frame.
processor IMotionProcessing Motion processing algorithm to apply to each video frame after /// motion detection is done.
Результат System

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

Process new video frame.

See ProcessFrame(UnmanagedImage) for additional details.

public ProcessFrame ( Bitmap videoFrame ) : float
videoFrame System.Drawing.Bitmap Video frame to process (detect motion in).
Результат float

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

Process new video frame.

See ProcessFrame(UnmanagedImage) for additional details.

public ProcessFrame ( BitmapData videoFrame ) : float
videoFrame System.Drawing.Imaging.BitmapData Video frame to process (detect motion in).
Результат float

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

Process new video frame.

The method first of all applies motion detection algorithm to the specified video frame to calculate motion level and motion frame. After this it applies motion processing algorithm (if it was set) to do further post processing, like highlighting motion areas, counting moving objects, etc.

In the case if MotionZones property is set, this method will perform motion filtering right after motion algorithm is done and before passing motion frame to motion processing algorithm. The method does filtering right on the motion frame, which is produced by motion detection algorithm. At the same time the method recalculates motion level and returns new value, which takes motion zones into account (but the new value is not set back to motion detection algorithm' IMotionDetector.MotionLevel property).

public ProcessFrame ( UnmanagedImage videoFrame ) : float
videoFrame Accord.Imaging.UnmanagedImage Video frame to process (detect motion in).
Результат float

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

Reset motion detector to initial state.

The method resets motion detection and motion processing algotithms by calling their IMotionDetector.Reset and IMotionProcessing.Reset methods.

public Reset ( ) : void
Результат void