org.opencv.video

## Class BackgroundSubtractorKNN

- java.lang.Object
- - org.opencv.core.Algorithm
  - - org.opencv.video.BackgroundSubtractor
    - - org.opencv.video.BackgroundSubtractorKNN

-     public class BackgroundSubtractorKNN
      extends BackgroundSubtractor

  K-nearest neighbours - based Background/Foreground Segmentation Algorithm. The class implements the K-nearest neighbours background subtraction described in CITE: Zivkovic2006 . Very efficient if number of foreground pixels is low.

- - ### Field Summary

    - ### Fields inherited from class org.opencv.core.Algorithm

      `nativeObj`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `BackgroundSubtractorKNN(long addr)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static BackgroundSubtractorKNN` | `__fromPtr__(long addr)`
    `protected void` | `finalize()`
    `boolean` | `getDetectShadows()` Returns the shadow detection flag If true, the algorithm detects shadows and marks them.
    `double` | `getDist2Threshold()` Returns 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.
    `int` | `getHistory()` Returns the number of last frames that affect the background model
    `int` | `getkNNSamples()` Returns the number of neighbours, the k in the kNN.
    `int` | `getNSamples()` Returns the number of data samples in the background model
    `double` | `getShadowThreshold()` Returns the shadow threshold A shadow is detected if pixel is a darker version of the background.
    `int` | `getShadowValue()` Returns the shadow value Shadow value is the value used to mark shadows in the foreground mask.
    `void` | `setDetectShadows(boolean detectShadows)` Enables or disables shadow detection
    `void` | `setDist2Threshold(double _dist2Threshold)` Sets the threshold on the squared distance
    `void` | `setHistory(int history)` Sets the number of last frames that affect the background model
    `void` | `setkNNSamples(int _nkNN)` Sets the k in the kNN.
    `void` | `setNSamples(int _nN)` Sets the number of data samples in the background model.
    `void` | `setShadowThreshold(double threshold)` Sets the shadow threshold
    `void` | `setShadowValue(int value)` Sets the shadow value

    - ### Methods inherited from class org.opencv.video.BackgroundSubtractor

      `apply, apply, getBackgroundImage`

    - ### Methods inherited from class org.opencv.core.Algorithm

      `clear, empty, getDefaultName, getNativeObjAddr, save`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BackgroundSubtractorKNN

          protected BackgroundSubtractorKNN(long addr)

  - ### Method Detail

    - #### __fromPtr__

          public static BackgroundSubtractorKNN __fromPtr__(long addr)

    - #### getDetectShadows

          public boolean getDetectShadows()

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

    - #### getDist2Threshold

          public double getDist2Threshold()

      Returns 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.
      Returns:
        automatically generated

    - #### getShadowThreshold

          public double getShadowThreshold()

      Returns 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.
      Returns:
        automatically generated

    - #### getHistory

          public int getHistory()

      Returns the number of last frames that affect the background model
      Returns:
        automatically generated

    - #### getNSamples

          public int getNSamples()

      Returns the number of data samples in the background model
      Returns:
        automatically generated

    - #### getShadowValue

          public int getShadowValue()

      Returns 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.
      Returns:
        automatically generated

    - #### getkNNSamples

          public int getkNNSamples()

      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.
      Returns:
        automatically generated

    - #### setDetectShadows

          public void setDetectShadows(boolean detectShadows)

      Enables or disables shadow detection
      Parameters:
        `detectShadows` - automatically generated

    - #### setDist2Threshold

          public void setDist2Threshold(double _dist2Threshold)

      Sets the threshold on the squared distance
      Parameters:
        `_dist2Threshold` - automatically generated

    - #### setHistory

          public void setHistory(int history)

      Sets the number of last frames that affect the background model
      Parameters:
        `history` - automatically generated

    - #### setNSamples

          public void setNSamples(int _nN)

      Sets the number of data samples in the background model. The model needs to be reinitalized to reserve memory.
      Parameters:
        `_nN` - automatically generated

    - #### setShadowThreshold

          public void setShadowThreshold(double threshold)

      Sets the shadow threshold
      Parameters:
        `threshold` - automatically generated

    - #### setShadowValue

          public void setShadowValue(int value)

      Sets the shadow value
      Parameters:
        `value` - automatically generated

    - #### setkNNSamples

          public void setkNNSamples(int _nkNN)

      Sets the k in the kNN. How many nearest neighbours need to match.
      Parameters:
        `_nkNN` - automatically generated

    - #### finalize

          protected void finalize()
                           throws Throwable

      Overrides:
        `finalize` in class `BackgroundSubtractor`
      Throws:
        `Throwable`

Generated on Thu Jul 25 2019 21:39:44 UTC / OpenCV 3.4.7