Class CameraCoveredDetector
- Namespace
- VisioForge.Core.CV
- Assembly
- VisioForge.Core.CV.dll
Detects when a camera lens is covered or obscured using edge detection algorithms.
public class CameraCoveredDetector : IDisposable, IVideoProcessorInheritance
Implements
-
IVideoProcessor
Inherited Members
Remarks
The VisioForge.Core.CV.CameraCoveredDetector class analyzes video frames to determine if the camera view is blocked by an object or covering. It uses Canny edge detection to count the number of edges in each frame; when the edge count falls below a threshold, it indicates the camera is likely covered. This is useful for surveillance systems, security applications, and monitoring whether a camera has been tampered with or blocked.
Constructors
CameraCoveredDetector()
Initializes a new instance of the VisioForge.Core.CV.CameraCoveredDetector class.
public CameraCoveredDetector()Properties
FramesToSkip
Gets or sets the number of frames to skip between detections.
public int FramesToSkip { get; set; }Property Value
Remarks
Increasing this value improves performance by analyzing fewer frames but may delay detection of camera coverage. For real-time applications processing 30fps video, a skip value of 5-10 still provides timely notifications while reducing CPU usage.
Threshold
Gets or sets the threshold level for determining if the camera is covered.
public int Threshold { get; set; }Property Value
Remarks
This threshold must be tuned based on your specific camera and scene:
- Higher quality cameras with more detail require higher thresholds
- Complex scenes (many objects/textures) have higher normal edge counts
- Simple scenes (blank walls, sky) have lower normal edge counts
VideoScale
Gets or sets the scale factor for video processing to improve performance.
public double VideoScale { get; set; }Property Value
Remarks
Reducing the scale improves performance significantly while maintaining accuracy for coverage detection. A typical value is 0.25-0.5 for HD video sources.
Methods
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected virtual void Dispose(bool disposing)Parameters
disposingbool-
trueto release both managed and unmanaged resources;falseto release only unmanaged resources.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()~CameraCoveredDetector()
Finalizes an instance of the VisioForge.Core.CV.CameraCoveredDetector class.
protected ~CameraCoveredDetector()GetSupportedFrameFormats()
Gets the video frame formats supported by this processor.
public VideoFormatX[] GetSupportedFrameFormats()Returns
- VideoFormatX[]
-
An array containing VisioForge.Core.Types.X.VideoFormatX.RGB, which is the required format for processing.
ProcessFrame(VideoFrame)
Processes the frame. Frame may be skipped according to the settings.
public void ProcessFrame(VideoFrame frame)Parameters
frameVideoFrame-
The frame.
ProcessFrame(VideoFrameX)
Processes a video frame to detect if the camera is covered.
public void ProcessFrame(VideoFrameX frame)Parameters
frameVideoFrameX-
The video frame to analyze. Must be in RGB or BGR format.
Remarks
This method converts the frame to grayscale, applies Canny edge detection, and counts
the number of edge pixels. If the count is below the threshold and enough frames have
been processed (based on VisioForge.Core.CV.CameraCoveredDetector.FramesToSkip), the VisioForge.Core.CV.CameraCoveredDetector.OnCameraCovered
event is raised. Frames are skipped according to the FramesToSkip setting to improve performance.
Exceptions
- Exception
-
Thrown when the frame format is not RGB or BGR.
SetContext(BaseContext)
Sets the context.
public void SetContext(BaseContext context)Parameters
contextBaseContext-
The context.
OnCameraCovered
Occurs when the camera is detected as being covered or obscured.
public event EventHandler<CameraCoveredDetectorEventArgs> OnCameraCoveredEvent Type
Remarks
This event is raised when the edge count falls below the VisioForge.Core.CV.CameraCoveredDetector.Threshold value, indicating the camera view is likely blocked. The event args contain the actual edge count which can be logged for threshold tuning purposes.