Click or drag to resize
Accord.NET (logo)

CustomFrameDifferenceDetector Class

Motion detector based on difference with predefined background frame.
Inheritance Hierarchy
SystemObject
  Accord.Vision.MotionCustomFrameDifferenceDetector

Namespace:  Accord.Vision.Motion
Assembly:  Accord.Vision (in Accord.Vision.dll) Version: 3.8.0
Syntax
public class CustomFrameDifferenceDetector : IMotionDetector
Request Example View Source

The CustomFrameDifferenceDetector type exposes the following members.

Constructors
  NameDescription
Public methodCustomFrameDifferenceDetector
Initializes a new instance of the CustomFrameDifferenceDetector class.
Public methodCustomFrameDifferenceDetector(Boolean)
Initializes a new instance of the CustomFrameDifferenceDetector class.
Public methodCustomFrameDifferenceDetector(Boolean, Boolean)
Initializes a new instance of the CustomFrameDifferenceDetector class.
Top
Properties
  NameDescription
Public propertyDifferenceThreshold
Difference threshold value, [1, 255].
Public propertyKeepObjectsEdges
Restore objects edges after noise suppression or not.
Public propertyMotionFrame
Motion frame containing detected areas of motion.
Public propertyMotionLevel
Motion level value, [0, 1].
Public propertySuppressNoise
Suppress noise in video frames or not.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodProcessFrame
Process new video frame.
Public methodReset
Reset motion detector to initial state.
Public methodSetBackgroundFrame(Bitmap)
Set background frame.
Public methodSetBackgroundFrame(BitmapData)
Set background frame.
Public methodSetBackgroundFrame(UnmanagedImage)
Set background frame.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

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.

Note Note
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.

Note Note
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
    }
}
See Also