Class PIIRedactionBlock
- Namespace
- VisioForge.Core.MediaBlocks.AI
- Assembly
- VisioForge.Core.AI.dll
A PII redaction media block. Detects faces (YuNet), vehicle license plates (FastALPR detector), and on-screen text (PaddleOCR detector, with an optional regex filter on the recognized text) and obscures them in-place with a Gaussian blur, pixelation, or a solid fill. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals.
public class PIIRedactionBlock : MediaBlock, IMediaBlockInternals, IVideoProcessingBlock, IMediaBlock, IDisposableInheritance
-
MediaBlock
Implements
-
IMediaBlockInternalsIVideoProcessingBlockIMediaBlock
Inherited Members
-
MediaBlock._isBuiltMediaBlock._pipelineMediaBlock._pipelineCtxMediaBlock.GetPipelineContext()MediaBlock.SetPipelineContext(BlockPipelineContext)MediaBlock.SetPipeline(MediaBlocksPipeline)MediaBlock.ContextMediaBlock.NameMediaBlock.IsBuiltMediaBlock.OwnerMediaBlock.TypeMediaBlock.IDMediaBlock.InputMediaBlock.InputsMediaBlock.OutputMediaBlock.OutputsMediaBlock.HasInputsMediaBlock.HasOutputsMediaBlock.Build()MediaBlock.CreateElements()MediaBlock.AddElementsToPipeline()MediaBlock.RemoveElementsFromPipeline()MediaBlock.DeepCopy(string)MediaBlock.Reset()MediaBlock.ToYAMLBlock()MediaBlock.ClearPads()MediaBlock.Dispose(bool)MediaBlock.Dispose()
Remarks
Detection runs on a background worker so live video never stalls; the streaming thread redacts every frame using the most recent regions, expanded by VisioForge.Core.Types.X.AI.PIIRedactionSettings.RegionPaddingPercent and held for VisioForge.Core.Types.X.AI.PIIRedactionSettings.RegionHoldTimeMs after the detector last reported them, so regions stay covered through object motion and detector flicker. Frames arriving before the first detection cycle completes pass through unredacted — for zero-leak redaction process files offline. Unlike the detection blocks, redaction always runs, even with no event subscriber.
Constructors
PIIRedactionBlock(PIIRedactionSettings)
Initializes a new instance of the VisioForge.Core.MediaBlocks.AI.PIIRedactionBlock class.
public PIIRedactionBlock(PIIRedactionSettings settings)Parameters
settingsPIIRedactionSettings-
The redaction settings. At least one category must be enabled with a valid model path.
Exceptions
- ArgumentNullException
-
Thrown when
settingsisnull.
Properties
ActiveProvider
Gets the execution provider that the detection sessions actually engaged. Valid after the block has been built; reports VisioForge.Core.Types.X.AI.OnnxExecutionProvider.CPU otherwise.
public OnnxExecutionProvider ActiveProvider { get; }Property Value
- OnnxExecutionProvider
DroppedFrameCount
Gets the number of frames that arrived while the background worker was still busy and were therefore skipped for detection (they are still redacted with the most recent regions).
public long DroppedFrameCount { get; }Property Value
Input
Gets the primary input pad.
public override MediaBlockPad Input { get; }Property Value
- MediaBlockPad
Inputs
Gets the array of all input pads.
public override MediaBlockPad[] Inputs { get; }Property Value
- MediaBlockPad[]
LastInferenceTimeMs
Gets the wall-clock time, in milliseconds, the most recent detection cycle took (all enabled categories). It runs on a background thread; use this to tune VisioForge.Core.Types.X.AI.PIIRedactionSettings.FramesToSkip to the hardware.
public float LastInferenceTimeMs { get; }Property Value
Output
Gets the primary output pad.
public override MediaBlockPad Output { get; }Property Value
- MediaBlockPad
Outputs
Gets the array of all output pads.
public override MediaBlockPad[] Outputs { get; }Property Value
- MediaBlockPad[]
Type
Gets the type of the media block.
public override MediaBlockType Type { get; }Property Value
- MediaBlockType
Methods
Build()
Constructs the internal GStreamer elements and pads for this block.
public override bool Build()Returns
- bool
-
trueif successful,falseotherwise.
CleanUp()
Cleans up internal resources, specifically the GStreamer element.
public void CleanUp()Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected override void Dispose(bool disposing)Parameters
disposingbool-
trueto release both managed and unmanaged resources;falseto release only unmanaged resources.
GetCore()
Gets the core GStreamer element wrapped by this block.
public BaseElement GetCore()Returns
- BaseElement
-
The VisioForge.Core.GStreamer.Base.BaseElement wrapper, or
nullif not built yet.
GetElement()
Gets the GStreamer element instance.
public Element GetElement()Returns
- Element
-
The Gst.Element, or
nullif not built yet.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the pipeline context for this block.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The pipeline.
OnRegionsRedacted
Event raised for each detection cycle that finds at least one PII region. Raised on the background detection thread; only categories and boxes are reported — never recognized content.
public event EventHandler<PIIRegionsRedactedEventArgs> OnRegionsRedactedEvent Type
- EventHandler<PIIRegionsRedactedEventArgs>
See Also
-
MediaBlockIMediaBlockInternals