Table of Contents

Class MotionDetectionEventArgs

Namespace
VisioForge.Core.Types.Events
Assembly
VisioForge.Core.dll

Provides data for motion detection events, indicating the level of motion and a matrix representing motion areas.

public class MotionDetectionEventArgs : EventArgs

Inheritance

Inherited Members

Examples

// Assume an event handler is registered for a motion detection event.
public void OnMotionDetected(object sender, MotionDetectionEventArgs e)
{
    Console.WriteLine($"Motion detected! Level: {e.Level}");

    // The Matrix represents a grid of motion, where each byte corresponds to a cell.
    // A non-zero value indicates motion in that cell.
    if (e.Matrix != null)
    {
        Console.WriteLine("Motion Matrix (first 10 bytes): ");
        for (int i = 0; i < Math.Min(e.Matrix.Length, 10); i++)
        {
            Console.Write($"{e.Matrix[i]} ");
        }
        Console.WriteLine();
    }

    if (e.Level > 50) // Example threshold
    {
        Console.WriteLine("  Significant motion detected!");
        // Trigger an alarm, start recording, etc.
    }
}

Remarks

This class is used to convey information about detected movement within a video frame. The VisioForge.Core.Types.Events.MotionDetectionEventArgs.Level property provides an overall intensity of motion, while the VisioForge.Core.Types.Events.MotionDetectionEventArgs.Matrix offers a more granular view of where motion occurred within the frame. Motion detection works by analyzing frame-to-frame differences and can be configured with sensitivity thresholds and detection zones. The Level value typically ranges from 0 (no motion) to 100 (maximum motion), though exact interpretation depends on the detection algorithm. The Matrix is a byte array representing a grid overlaid on the video frame, with each element indicating motion intensity in that region. Grid dimensions are determined by the motion detector configuration and affect detection granularity. Applications can use motion events to trigger recording, send alerts, activate lights, or implement interactive features. Zone-based analysis of the Matrix allows different responses based on which areas of the frame show activity. These events may be raised frequently during continuous motion, so handlers should be efficient to avoid performance degradation. Consider implementing debouncing, throttling, or aggregation when processing motion events to reduce computational overhead. Events are typically raised on background processing threads, requiring thread-safe handling and UI marshaling.

Constructors

MotionDetectionEventArgs(int, byte[])

Initializes a new instance of the VisioForge.Core.Types.Events.MotionDetectionEventArgs class.

public MotionDetectionEventArgs(int level, byte[] matrix)

Parameters

level int

The motion level.

matrix byte[]

The motion matrix.

Properties

Level

Gets the overall level or intensity of motion detected. The interpretation of this value depends on the motion detection algorithm used.

public int Level { get; }

Property Value

int

Matrix

Gets a byte array representing a grid or matrix of motion activity. Each element in the array corresponds to a specific area in the video frame, with its value indicating the amount of motion in that area.

public byte[] Matrix { get; }

Property Value

byte[]