Class MotionDetectionExEventArgs
- Namespace
- VisioForge.Core.Types.Events
- Assembly
- VisioForge.Core.dll
Provides data for extended motion and object detection events. This class offers more detailed information about detected motion, including an overall motion level, detected objects, and a motion grid.
public class MotionDetectionExEventArgs : EventArgsInheritance
Inherited Members
Examples
// Assume an event handler is registered for an extended motion detection event.
public void OnMotionDetectedEx(object sender, MotionDetectionExEventArgs e)
{
Console.WriteLine($"Motion Detected (Extended)! Overall Level: {e.Level:F2} ({e.LevelPercent}%)");
if (e.ObjectsCount > 0)
{
Console.WriteLine($" Detected {e.ObjectsCount} moving objects.");
foreach (var objRect in e.ObjectRectangles)
{
Console.WriteLine($" Object at: {objRect}");
}
}
if (e.MotionGrid != null)
{
Console.WriteLine(" Motion Grid (sample):");
// Print a small portion of the motion grid for demonstration
for (int i = 0; i < Math.Min(e.MotionGrid.GetLength(0), 3); i++)
{
for (int j = 0; j < Math.Min(e.MotionGrid.GetLength(1), 5); j++)
{
Console.Write($"{e.MotionGrid[i, j]:F1} ");
}
Console.WriteLine();
}
}
if (e.LevelPercent > 75)
{
Console.WriteLine(" High level of activity detected!");
}
}
Remarks
This event argument is designed for advanced surveillance, security, and analytical applications where precise motion tracking and object identification are required. The VisioForge.Core.Types.Events.MotionDetectionExEventArgs.MotionGrid property provides a granular view of motion activity across the frame, allowing for detailed analysis of movement patterns. Level property provides overall motion intensity as a float value, while LevelPercent converts it to 0-100 range for easier interpretation. ObjectsCount and ObjectRectangles enable tracking of discrete moving objects detected through blob analysis or object segmentation. MotionGrid is a 2D array where each element represents motion percentage (0.0 to 1.0) in that grid cell. Grid dimensions are configurable and affect detection granularity and processing performance. Applications can implement zone-based alerts, heatmap visualizations, or trajectory tracking using the motion grid data. Object rectangles can be used for targeted tracking, counting, or triggering zone-specific actions. This extended motion detection is more computationally intensive than basic motion detection but provides richer analytical data. Consider adjusting grid resolution based on frame size and processing power - finer grids provide more detail but require more computation. Events are raised on background processing threads, requiring thread-safe handling and UI marshaling.
Constructors
MotionDetectionExEventArgs(float, int, Rect[], ref float[,])
Initializes a new instance of the VisioForge.Core.Types.Events.MotionDetectionExEventArgs class.
public MotionDetectionExEventArgs(float level, int objectsCount, Rect[] objectRectangles, ref float[,] motionGrid)Parameters
levelfloat-
The overall motion level.
objectsCountint-
The number of detected objects.
objectRectanglesRect[]-
An array of rectangles for detected moving objects.
motionGridfloat[,]-
A 2D array representing the motion levels of each grid cell.
Properties
Level
Gets the overall motion level, typically a floating-point value representing the intensity or percentage of change.
public float Level { get; }Property Value
LevelPercent
Gets the overall motion level as a percentage (0-100). This is derived from the VisioForge.Core.Types.Events.MotionDetectionExEventArgs.Level property.
public int LevelPercent { get; }Property Value
MotionGrid
Gets a 2D array representing the motion levels of each cell in a grid overlaying the video frame. Each element (float) indicates the percentage of change within that specific grid cell (e.g., 0.2 means 20% change). The dimensions of the array correspond to the configured grid height and width.
public float[,] MotionGrid { get; }Property Value
- float[,]
ObjectRectangles
Gets an array of VisioForge.Core.Types.Rect objects, representing the bounding boxes of detected moving objects. This is typically used with blob counting or object tracking processors.
public Rect[] ObjectRectangles { get; }Property Value
- Rect[]
ObjectsCount
Gets the total number of moving objects detected.
public int ObjectsCount { get; }