Show / Hide Table of Contents

Class BackgroundSubtractorKNN

K nearest neigbours algorithm

Inheritance
System.Object
DisposableObject
DisposableCvObject
Algorithm
BackgroundSubtractor
BackgroundSubtractorKNN
Implements
ICvPtrHolder
Inherited Members
BackgroundSubtractor.Apply(InputArray, OutputArray, Double)
BackgroundSubtractor.GetBackgroundImage(OutputArray)
Algorithm.Write(FileStorage)
Algorithm.Read(FileNode)
Algorithm.Empty
Algorithm.Save(String)
Algorithm.GetDefaultName()
DisposableCvObject.ptr
DisposableCvObject.CvPtr
DisposableObject.DataHandle
DisposableObject.IsDisposed
DisposableObject.IsEnabledDispose
DisposableObject.AllocatedMemory
DisposableObject.AllocatedMemorySize
DisposableObject.Dispose()
DisposableObject.Dispose(Boolean)
DisposableObject.AllocGCHandle(Object)
DisposableObject.AllocMemory(Int32)
DisposableObject.NotifyMemoryPressure(Int64)
DisposableObject.ThrowIfDisposed()
Namespace: OpenCvSharp
Assembly: OpenCvSharp.dll
Syntax
public class BackgroundSubtractorKNN : BackgroundSubtractor, ICvPtrHolder

Properties

| Improve this Doc View Source

DetectShadows

Returns the shadow detection flag. If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorKNN for details.

Declaration
public bool DetectShadows { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

Dist2Threshold

Gets or sets the threshold on the squared distance between the pixel and the sample. The threshold on the squared distance between the pixel and the sample to decide whether a pixel is close to a data sample.

Declaration
public double Dist2Threshold { get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

History

Gets or sets the number of last frames that affect the background model.

Declaration
public int History { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

KNNSamples

Returns the number of neighbours, the k in the kNN. K is the number of samples that need to be within dist2Threshold in order to decide that that pixel is matching the kNN background model.

Declaration
public int KNNSamples { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

NSamples

Gets or sets the number of data samples in the background model

Declaration
public int NSamples { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

ShadowThreshold

Gets or sets the shadow threshold. A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiara, Detecting Moving Shadows..., IEEE PAMI,2003.

Declaration
public double ShadowThreshold { get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

ShadowValue

Gets or sets the shadow value. Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0 in the mask always means background, 255 means foreground.

Declaration
public int ShadowValue { get; set; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

Create(Int32, Double, Boolean)

Creates KNN Background Subtractor

Declaration
public static BackgroundSubtractorKNN Create(int history = 500, double dist2Threshold = 400, bool detectShadows = true)
Parameters
Type Name Description
System.Int32 history

Length of the history.

System.Double dist2Threshold

Threshold on the squared distance between the pixel and the sample to decide whether a pixel is close to that sample. This parameter does not affect the background update.

System.Boolean detectShadows

If true, the algorithm will detect shadows and mark them. It decreases the speed a bit, so if you do not need this feature, set the parameter to false.

Returns
Type Description
BackgroundSubtractorKNN
| Improve this Doc View Source

DisposeManaged()

Releases managed resources

Declaration
protected override void DisposeManaged()
Overrides
DisposableObject.DisposeManaged()
| Improve this Doc View Source

DisposeUnmanaged()

Declaration
protected override void DisposeUnmanaged()
Overrides
DisposableCvObject.DisposeUnmanaged()
| Improve this Doc View Source

Get()

Declaration
public override IntPtr Get()
Returns
Type Description
IntPtr

Implements

ICvPtrHolder
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX