AForge.Vision
Motion processing algorithm, which highlights motion areas.
The aim of this motion processing algorithm is to highlight
motion areas with grid pattern of the specified color.
Sample usage:
// create motion detector
MotionDetector detector = new MotionDetector(
/* motion detection algorithm */,
new MotionAreaHighlighting( ) );
// continuously feed video frames to motion detector
while ( ... )
{
// process new video frame
detector.ProcessFrame( videoFrame );
}
Interface of motion processing algorithm.
The interface specifies methods, which should be implemented
by all motion processng algorithms - algorithm which perform further post processing
of detected motion, which is done by motion detection algorithms (see ).
Process video and motion frames doing further post processing after
performed motion detection.
Original video frame.
Motion frame provided by motion detection
algorithm (see ).
The method does father post processing of detected motion.
Type of motion post processing is specified by specific implementation
of the interface - it may motion
area highlighting, motion objects counting, etc.
Reset internal state of motion processing algorithm.
The method allows to reset internal state of motion processing
algorithm and prepare it for processing of next video stream or to restart
the algorithm.
Some motion processing algorithms may not have any stored internal
states and may just process provided video frames without relying on any motion
history etc. In this case such algorithms provide empty implementation of this method.
Initializes a new instance of the class.
Initializes a new instance of the class.
Color used to highlight motion regions.
Process video and motion frames doing further post processing after
performed motion detection.
Original video frame.
Motion frame provided by motion detection
algorithm (see ).
Processes provided motion frame and highlights motion areas
on the original video frame with specified color.
Motion frame is not 8 bpp image, but it must be so.
Video frame must be 8 bpp grayscale image or 24/32 bpp color image.
Reset internal state of motion processing algorithm.
The method allows to reset internal state of motion processing
algorithm and prepare it for processing of next video stream or to restart
the algorithm.
Color used to highlight motion regions.
Default value is set to red color.
Interface of motion detector algorithm.
The interface specifies methods, which should be implemented
by all motion detection algorithms - algorithms which perform processing of video
frames in order to detect motion. Amount of detected motion may be checked using
property. Also property may
be used in order to see all the detected motion areas. For example, the property
is used by motion processing algorithms for further motion post processing, like
highlighting motion areas, counting number of detected moving object, etc.
Process new video frame.
Video frame to process (detect motion in).
Processes new frame from video source and detects motion in it.
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.
Motion level value, [0, 1].
Amount of changes in the last processed frame. For example, if value of
this property equals to 0.1, then it means that last processed frame has 10% of changes
(however it is up to specific implementation to decide how to compare specified frame).
Motion frame containing detected areas of motion.
Motion frame is a grayscale image, which shows areas of detected motion.
All black pixels in the motion frame correspond to areas, where no motion is
detected. But white pixels correspond to areas, where motion is detected.
Motion processing algorithm, which counts separate moving objects and highlights them.
The aim of this motion processing algorithm is to count separate objects
in the motion frame, which is provided by motion detection algorithm.
In the case if property is set to ,
found objects are also highlighted on the original video frame. The algorithm
counts and highlights only those objects, which size satisfies
and properties.
The motion processing algorithm is supposed to be used only with motion detection
algorithms, which are based on finding difference with background frame
(see and
as simple implementations) and allow extract moving objects clearly.
Sample usage:
// create instance of motion detection algorithm
IMotionDetector motionDetector = new ... ;
// create instance of motion processing algorithm
BlobCountingObjectsProcessing motionProcessing = new BlobCountingObjectsProcessing( );
// create motion detector
MotionDetector detector = new MotionDetector( motionDetector, motionProcessing );
// continuously feed video frames to motion detector
while ( ... )
{
// process new video frame and check motion level
if ( detector.ProcessFrame( videoFrame ) > 0.02 )
{
// check number of detected objects
if ( motionProcessing.ObjectsCount > 1 )
{
// ...
}
}
}
Initializes a new instance of the class.
Initializes a new instance of the class.
Highlight motion regions or not (see property).
Initializes a new instance of the class.
Minimum width of acceptable object (see property).
Minimum height of acceptable object (see property).
Initializes a new instance of the class.
Minimum width of acceptable object (see property).
Minimum height of acceptable object (see property).
Color used to highlight motion regions.
Initializes a new instance of the class.
Minimum width of acceptable object (see property).
Minimum height of acceptable object (see property).
Highlight motion regions or not (see property).
Process video and motion frames doing further post processing after
performed motion detection.
Original video frame.
Motion frame provided by motion detection
algorithm (see ).
Processes provided motion frame and counts number of separate
objects, which size satisfies and
properties. In the case if property is
set to , the found object are also highlighted on the
original video frame.
Motion frame is not 8 bpp image, but it must be so.
Video frame must be 8 bpp grayscale image or 24/32 bpp color image.
Reset internal state of motion processing algorithm.
The method allows to reset internal state of motion processing
algorithm and prepare it for processing of next video stream or to restart
the algorithm.
Highlight motion regions or not.
The property specifies if detected moving objects should be highlighted
with rectangle or not.
Default value is set to .
Turning the value on leads to additional processing time of video frame.
Color used to highlight motion regions.
Default value is set to red color.
Minimum width of acceptable object.
The property sets minimum width of an object to count and highlight. If
objects have smaller width, they are not counted and are not highlighted.
Default value is set to 10.
Minimum height of acceptable object.
The property sets minimum height of an object to count and highlight. If
objects have smaller height, they are not counted and are not highlighted.
Default value is set to 10.
Number of detected objects.
The property provides number of moving objects detected by
the last call of method.
Rectangles of moving objects.
The property provides array of moving objects' rectangles
detected by the last call of method.
Motion processing algorithm, which performs grid processing of motion frame.
The aim of this motion processing algorithm is to do grid processing
of motion frame. This means that entire motion frame is divided by a grid into
certain amount of cells and the motion level is calculated for each cell. The
information about each cell's motion level may be retrieved using
property.
In addition the algorithm can highlight those cells, which have motion
level above the specified threshold (see
property). To enable this it is required to set
property to .
Sample usage:
// create instance of motion detection algorithm
IMotionDetector motionDetector = new ... ;
// create instance of motion processing algorithm
GridMotionAreaProcessing motionProcessing = new GridMotionAreaProcessing( 16, 16 );
// create motion detector
MotionDetector detector = new MotionDetector( motionDetector, motionProcessing );
// continuously feed video frames to motion detector
while ( ... )
{
// process new video frame
detector.ProcessFrame( videoFrame );
// check motion level in 5th row 8th column
if ( motionProcessing.MotionGrid[5, 8] > 0.15 )
{
// ...
}
}
Initializes a new instance of the class.
Initializes a new instance of the class.
Width of motion grid (see property).
Height of motion grid (see property).
Initializes a new instance of the class.
Width of motion grid (see property).
Height of motion grid (see property).
Highlight motion regions or not (see property).
Initializes a new instance of the class.
Width of motion grid (see property).
Height of motion grid (see property).
Highlight motion regions or not (see property).
Motion amount to highlight cell (see property).
Process video and motion frames doing further post processing after
performed motion detection.
Original video frame.
Motion frame provided by motion detection
algorithm (see ).
Processes provided motion frame and calculates motion level
for each grid's cell. In the case if property is
set to , the cell with motion level above threshold are
highlighted.
Motion frame is not 8 bpp image, but it must be so.
Video frame must be 8 bpp grayscale image or 24/32 bpp color image.
Reset internal state of motion processing algorithm.
The method allows to reset internal state of motion processing
algorithm and prepare it for processing of next video stream or to restart
the algorithm.
Color used to highlight motion regions.
Default value is set to red color.
Highlight motion regions or not.
The property specifies if motion grid should be highlighted -
if cell, which have motion level above the
specified value, should be highlighted.
Default value is set to .
Turning the value on leads to additional processing time of video frame.
Motion amount to highlight cell.
The property specifies motion level threshold for highlighting grid's
cells. If motion level of a certain cell is higher than this value, then the cell
is highlighted.
Default value is set to 0.15.
Motion levels of each grid's cell.
The property represents an array of size
x, which keeps motion level
of each grid's cell. If certain cell has motion level equal to 0.2, then it
means that this cell has 20% of changes.
Width of motion grid, [2, 64].
The property specifies motion grid's width - number of grid' columns.
Default value is set to 16.
Height of motion grid, [2, 64].
The property specifies motion grid's height - number of grid' rows.
Default value is set to 16.
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 , but to .NET's class
as well.
In addition to wrapping of motion detection and processing algorthms, the class provides
some additional functionality. Using 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
}
}
Initializes a new instance of the class.
Motion detection algorithm to apply to each video frame.
Initializes a new instance of the class.
Motion detection algorithm to apply to each video frame.
Motion processing algorithm to apply to each video frame after
motion detection is done.
Process new video frame.
Video frame to process (detect motion in).
Returns amount of motion, which is provided
property of the motion detection algorithm in use.
See for additional details.
Process new video frame.
Video frame to process (detect motion in).
Returns amount of motion, which is provided
property of the motion detection algorithm in use.
See for additional details.
Process new video frame.
Video frame to process (detect motion in).
Returns amount of motion, which is provided
property of the motion detection algorithm in use.
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 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' property).
Reset motion detector to initial state.
The method resets motion detection and motion processing algotithms by calling
their and methods.
Motion detection algorithm to apply to each video frame.
The property sets motion detection algorithm, which is used by
method in order to calculate
motion level and
motion frame.
Motion processing algorithm to apply to each video frame after
motion detection is done.
The property sets motion processing algorithm, which is used by
method after motion detection in order to do further
post processing of motion frames. The aim of further post processing depends on
actual implementation of the specified motion processing algorithm - it can be
highlighting of motion area, objects counting, etc.
Set of zones to detect motion in.
The property keeps array of rectangular zones, which are observed for motion detection.
Motion outside of these zones is ignored.
In the case if this property is set, the method
will filter out all motion witch was detected by motion detection algorithm, but is not
located in the specified zones.
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 property.
Although the class may be used on its own to perform motion detection, it is preferred
to use it in conjunction with 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
}
}
Initializes a new instance of the class.
Initializes a new instance of the class.
Suppress noise in video frames or not (see property).
Process new video frame.
Video frame to process (detect motion in).
Processes new frame from video source and detects motion in it.
Check property to get information about amount of motion
(changes) in the processed frame.
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.
Difference threshold value, [1, 255].
The value specifies the amount off difference between pixels, which is treated
as motion pixel.
Default value is set to 15.
Motion level value, [0, 1].
Amount of changes in the last processed frame. For example, if value of
this property equals to 0.1, then it means that last processed frame has 10% difference
with previous frame.
Motion frame containing detected areas of motion.
Motion frame is a grayscale image, which shows areas of detected motion.
All black pixels in the motion frame correspond to areas, where no motion is
detected. But white pixels correspond to areas, where motion is detected.
The property is set to after processing of the first
video frame by the algorithm.
Suppress noise in video frames or not.
The value specifies if additional filtering should be
done to suppress standalone noisy pixels by applying 3x3 erosion image processing
filter.
Default value is set to .
Turning the value on leads to more processing time of video frame.
Motion processing algorithm, which highlights border of motion areas.
The aim of this motion processing algorithm is to highlight
borders of motion areas with the specified color.
The motion processing algorithm is supposed to be used only with motion detection
algorithms, which are based on finding difference with background frame
(see and
as simple implementations) and allow extract moving objects clearly.
Sample usage:
// create motion detector
MotionDetector detector = new MotionDetector(
/* motion detection algorithm */,
new MotionBorderHighlighting( ) );
// continuously feed video frames to motion detector
while ( ... )
{
// process new video frame
detector.ProcessFrame( videoFrame );
}
Initializes a new instance of the class.
Initializes a new instance of the class.
Color used to highlight motion regions.
Process video and motion frames doing further post processing after
performed motion detection.
Original video frame.
Motion frame provided by motion detection
algorithm (see ).
Processes provided motion frame and highlights borders of motion areas
on the original video frame with specified color.
Motion frame is not 8 bpp image, but it must be so.
Video frame must be 8 bpp grayscale image or 24/32 bpp color image.
Reset internal state of motion processing algorithm.
The method allows to reset internal state of motion processing
algorithm and prepare it for processing of next video stream or to restart
the algorithm.
Color used to highlight motion regions.
Default value is set to red color.
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 property.
In the case if precise motion area's borders are required (for example,
for further motion post processing), then property
may be used to restore borders after noise suppression.
In the case if custom background frame is not specified by using
method, the algorithm takes first video frame
as a background frame and calculates difference of further video frames with it.
Unlike 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
}
}
Initializes a new instance of the class.
Initializes a new instance of the class.
Suppress noise in video frames or not (see property).
Initializes a new instance of the class.
Suppress noise in video frames or not (see property).
Restore objects edges after noise suppression or not (see property).
Process new video frame.
Video frame to process (detect motion in).
Processes new frame from video source and detects motion in it.
Check property to get information about amount of motion
(changes) in the processed frame.
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
method, this method does not reset it.
The method resets only automatically generated background frame.
Set background frame.
Background frame to set.
The method sets background frame, which will be used to calculate
difference with.
Set background frame.
Background frame to set.
The method sets background frame, which will be used to calculate
difference with.
Set background frame.
Background frame to set.
The method sets background frame, which will be used to calculate
difference with.
Difference threshold value, [1, 255].
The value specifies the amount off difference between pixels, which is treated
as motion pixel.
Default value is set to 15.
Motion level value, [0, 1].
Amount of changes in the last processed frame. For example, if value of
this property equals to 0.1, then it means that last processed frame has 10% difference
with defined background frame.
Motion frame containing detected areas of motion.
Motion frame is a grayscale image, which shows areas of detected motion.
All black pixels in the motion frame correspond to areas, where no motion is
detected. But white pixels correspond to areas, where motion is detected.
The property is set to after processing of the first
video frame by the algorithm in the case if custom background frame was not set manually
by using method (it will be not
after second call in this case). If correct custom background
was set then the property should bet set to estimated motion frame after
method call.
Suppress noise in video frames or not.
The value specifies if additional filtering should be
done to suppress standalone noisy pixels by applying 3x3 erosion image processing
filter. See property, if it is required to restore
edges of objects, which are not noise.
Default value is set to .
Turning the value on leads to more processing time of video frame.
Restore objects edges after noise suppression or not.
The value specifies if additional filtering should be done
to restore objects' edges after noise suppression by applying 3x3 dilatation
image processing filter.
Default value is set to .
Turning the value on leads to more processing time of video frame.
Motion detector based on simple background modeling.
The class implements motion detection algorithm, which is based on
difference of current video frame with modeled 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 property.
In the case if precise motion area's borders are required (for example,
for further motion post processing), then property
may be used to restore borders after noise suppression.
As the first approximation of background frame, the first frame of video stream is taken.
During further video processing the background frame is constantly updated, so it
changes in the direction to decrease difference with current video frame (the background
frame is moved towards current frame). See
properties, which control the rate of
background frame update.
Unlike motion detection algorithm, this algorithm
allows to identify quite clearly all objects, which are not part of the background (scene) -
most likely moving objects. And unlike motion
detection algorithm, this algorithm includes background adaptation feature, which allows it
to update its modeled background frame in order to take scene changes into account.
Because of the adaptation feature of the algorithm, it may adopt
to background changes, what algorithm can not do.
However, if moving object stays on the scene for a while (so algorithm adopts to it and does
not treat it as a new moving object any more) and then starts to move again, the algorithm may
find two moving objects - the true one, which is really moving, and the false one, which does not (the
place, where the object stayed for a while).
The algorithm is not applicable to such cases, when moving object resides
in camera's view most of the time (laptops camera monitoring a person sitting in front of it,
for example). The algorithm is mostly supposed for cases, when camera monitors some sort
of static scene, where moving objects appear from time to time - street, road, corridor, etc.
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
}
}
Initializes a new instance of the class.
Initializes a new instance of the class.
Suppress noise in video frames or not (see property).
Initializes a new instance of the class.
Suppress noise in video frames or not (see property).
Restore objects edges after noise suppression or not (see property).
Process new video frame.
Video frame to process (detect motion in).
Processes new frame from video source and detects motion in it.
Check property to get information about amount of motion
(changes) in the processed frame.
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.
Difference threshold value, [1, 255].
The value specifies the amount off difference between pixels, which is treated
as motion pixel.
Default value is set to 15.
Motion level value, [0, 1].
Amount of changes in the last processed frame. For example, if value of
this property equals to 0.1, then it means that last processed frame has 10% difference
with modeled background frame.
Motion frame containing detected areas of motion.
Motion frame is a grayscale image, which shows areas of detected motion.
All black pixels in the motion frame correspond to areas, where no motion is
detected. But white pixels correspond to areas, where motion is detected.
The property is set to after processing of the first
video frame by the algorithm.
Suppress noise in video frames or not.
The value specifies if additional filtering should be
done to suppress standalone noisy pixels by applying 3x3 erosion image processing
filter. See property, if it is required to restore
edges of objects, which are not noise.
Default value is set to .
Turning the value on leads to more processing time of video frame.
Restore objects edges after noise suppression or not.
The value specifies if additional filtering should be done
to restore objects' edges after noise suppression by applying 3x3 dilatation
image processing filter.
Default value is set to .
Turning the value on leads to more processing time of video frame.
Frames per background update, [1, 50].
The value controls the speed of modeled background adaptation to
scene changes. After each specified amount of frames the background frame is updated
in the direction to decrease difference with current processing frame.
Default value is set to 2.
The property has effect only in the case if
property is set to 0. Otherwise it does not have effect and background
update is managed according to the
property settings.
Milliseconds per background update, [0, 5000].
The value represents alternate way of controlling the speed of modeled
background adaptation to scene changes. The value sets number of milliseconds, which
should elapse between two consequent video frames to result in background update
for one intensity level. For example, if this value is set to 100 milliseconds and
the amount of time elapsed between two last video frames equals to 350, then background
frame will be update for 3 intensity levels in the direction to decrease difference
with current video frame (the remained 50 milliseconds will be added to time difference
between two next consequent frames, so the accuracy is preserved).
Unlike background update method controlled using
method, the method guided by this property is not affected by changes
in frame rates. If, for some reasons, a video source starts to provide delays between
frames (frame rate drops down), the amount of background update still stays consistent.
When background update is controlled by this property, it is always possible to estimate
amount of time required to change, for example, absolutely black background (0 intensity
values) into absolutely white background (255 intensity values). If value of this
property is set to 100, then it will take approximately 25.5 seconds for such update
regardless of frame rate.
Background update controlled by this property is slightly slower then
background update controlled by property,
so it has a bit greater impact on performance.
If this property is set to 0, then corresponding background updating
method is not used (turned off), but background update guided by
property is used.
Default value is set to 0.