Package 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.
- 
- 
Constructor SummaryConstructors Modifier Constructor Description protectedBackgroundSubtractorKNN(long addr)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BackgroundSubtractorKNN__fromPtr__(long addr)protected voidfinalize()booleangetDetectShadows()Returns the shadow detection flag If true, the algorithm detects shadows and marks them.doublegetDist2Threshold()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.intgetHistory()Returns the number of last frames that affect the background modelintgetkNNSamples()Returns the number of neighbours, the k in the kNN.intgetNSamples()Returns the number of data samples in the background modeldoublegetShadowThreshold()Returns the shadow threshold A shadow is detected if pixel is a darker version of the background.intgetShadowValue()Returns the shadow value Shadow value is the value used to mark shadows in the foreground mask.voidsetDetectShadows(boolean detectShadows)Enables or disables shadow detectionvoidsetDist2Threshold(double _dist2Threshold)Sets the threshold on the squared distancevoidsetHistory(int history)Sets the number of last frames that affect the background modelvoidsetkNNSamples(int _nkNN)Sets the k in the kNN.voidsetNSamples(int _nN)Sets the number of data samples in the background model.voidsetShadowThreshold(double threshold)Sets the shadow thresholdvoidsetShadowValue(int value)Sets the shadow value- 
Methods inherited from class org.opencv.video.BackgroundSubtractorapply, apply, getBackgroundImage
 - 
Methods inherited from class org.opencv.core.Algorithmclear, empty, getDefaultName, getNativeObjAddr, save
 
- 
 
- 
- 
- 
Method Detail- 
__fromPtr__public static BackgroundSubtractorKNN __fromPtr__(long addr) 
 - 
getHistorypublic int getHistory() Returns the number of last frames that affect the background model- Returns:
- automatically generated
 
 - 
setHistorypublic void setHistory(int history) Sets the number of last frames that affect the background model- Parameters:
- history- automatically generated
 
 - 
getNSamplespublic int getNSamples() Returns the number of data samples in the background model- Returns:
- automatically generated
 
 - 
setNSamplespublic 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
 
 - 
getDist2Thresholdpublic 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
 
 - 
setDist2Thresholdpublic void setDist2Threshold(double _dist2Threshold) Sets the threshold on the squared distance- Parameters:
- _dist2Threshold- automatically generated
 
 - 
getkNNSamplespublic 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
 
 - 
setkNNSamplespublic void setkNNSamples(int _nkNN) Sets the k in the kNN. How many nearest neighbours need to match.- Parameters:
- _nkNN- automatically generated
 
 - 
getDetectShadowspublic boolean getDetectShadows() Returns the shadow detection flag If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorKNN for details.- Returns:
- automatically generated
 
 - 
setDetectShadowspublic void setDetectShadows(boolean detectShadows) Enables or disables shadow detection- Parameters:
- detectShadows- automatically generated
 
 - 
getShadowValuepublic 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
 
 - 
setShadowValuepublic void setShadowValue(int value) Sets the shadow value- Parameters:
- value- automatically generated
 
 - 
getShadowThresholdpublic 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
 
 - 
setShadowThresholdpublic void setShadowThreshold(double threshold) Sets the shadow threshold- Parameters:
- threshold- automatically generated
 
 - 
finalizeprotected void finalize() throws java.lang.Throwable- Overrides:
- finalizein class- BackgroundSubtractor
- Throws:
- java.lang.Throwable
 
 
- 
 
-