C# 클래스 AForge.Vision.Motion.CustomFrameDifferenceDetector

Motion detector based on difference with predefined background frame.

The class implements motion detection algorithm, which is based on difference of current video frame with predefined background frame. 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.

In the case if precise motion area's borders are required (for example, for further motion post processing), then KeepObjectsEdges property may be used to restore borders after noise suppression.

In the case if custom background frame is not specified by using SetBackgroundFrame(Bitmap) method, the algorithm takes first video frame as a background frame and calculates difference of further video frames with it.

Unlike TwoFramesDifferenceDetector motion detection algorithm, this algorithm allows to identify quite clearly all objects, which are not part of the background (scene) - most likely moving objects.

Sample usage:

// create motion detector MotionDetector detector = new MotionDetector( new CustomFrameDifferenceDetector( ), 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
파일 보기 프로젝트 열기: holisticware-admin/MonoVersal.AForgeNET 1 사용 예제들

공개 메소드들

메소드 설명
CustomFrameDifferenceDetector ( ) : System

Initializes a new instance of the CustomFrameDifferenceDetector class.

CustomFrameDifferenceDetector ( bool suppressNoise ) : System

Initializes a new instance of the CustomFrameDifferenceDetector class.

CustomFrameDifferenceDetector ( bool suppressNoise, bool keepObjectEdges ) : System

Initializes a new instance of the CustomFrameDifferenceDetector class.

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.

In the case if custom background frame was set using SetBackgroundFrame(Bitmap) method, this method does not reset it. The method resets only automatically generated background frame.

SetBackgroundFrame ( Bitmap backgroundFrame ) : void

Set background frame.

The method sets background frame, which will be used to calculate difference with.

SetBackgroundFrame ( BitmapData backgroundFrame ) : void

Set background frame.

The method sets background frame, which will be used to calculate difference with.

SetBackgroundFrame ( UnmanagedImage backgroundFrame ) : void

Set background frame.

The method sets background frame, which will be used to calculate difference with.

비공개 메소드들

메소드 설명
Reset ( bool force ) : void

메소드 상세

CustomFrameDifferenceDetector() 공개 메소드

Initializes a new instance of the CustomFrameDifferenceDetector class.
public CustomFrameDifferenceDetector ( ) : System
리턴 System

CustomFrameDifferenceDetector() 공개 메소드

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

CustomFrameDifferenceDetector() 공개 메소드

Initializes a new instance of the CustomFrameDifferenceDetector class.
public CustomFrameDifferenceDetector ( bool suppressNoise, bool keepObjectEdges ) : System
suppressNoise bool Suppress noise in video frames or not (see property).
keepObjectEdges bool Restore objects edges after noise suppression or not (see property).
리턴 System

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.

In the case if custom background frame was set using SetBackgroundFrame(Bitmap) method, this method does not reset it. The method resets only automatically generated background frame.

public Reset ( ) : void
리턴 void

SetBackgroundFrame() 공개 메소드

Set background frame.

The method sets background frame, which will be used to calculate difference with.

public SetBackgroundFrame ( Bitmap backgroundFrame ) : void
backgroundFrame System.Drawing.Bitmap Background frame to set.
리턴 void

SetBackgroundFrame() 공개 메소드

Set background frame.

The method sets background frame, which will be used to calculate difference with.

public SetBackgroundFrame ( BitmapData backgroundFrame ) : void
backgroundFrame System.Drawing.Imaging.BitmapData Background frame to set.
리턴 void

SetBackgroundFrame() 공개 메소드

Set background frame.

The method sets background frame, which will be used to calculate difference with.

public SetBackgroundFrame ( UnmanagedImage backgroundFrame ) : void
backgroundFrame AForge.Imaging.UnmanagedImage Background frame to set.
리턴 void