@Namespace(value="cv") @Properties(inherit=opencv_video.class) public class BackgroundSubtractorKNN extends BackgroundSubtractor
The class implements the K-nearest neighbours background subtraction described in \cite Zivkovic2006 . Very efficient if number of foreground pixels is low.
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Constructor and Description |
---|
BackgroundSubtractorKNN(Pointer p)
Pointer cast constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
getDetectShadows()
\brief Returns the shadow detection flag
|
double |
getDist2Threshold()
\brief Returns the threshold on the squared distance between the pixel and the sample
|
int |
getHistory()
\brief Returns the number of last frames that affect the background model
|
int |
getkNNSamples()
\brief Returns the number of neighbours, the k in the kNN.
|
int |
getNSamples()
\brief Returns the number of data samples in the background model
|
double |
getShadowThreshold()
\brief Returns the shadow threshold
|
int |
getShadowValue()
\brief Returns the shadow value
|
void |
setDetectShadows(boolean detectShadows)
\brief Enables or disables shadow detection
|
void |
setDist2Threshold(double _dist2Threshold)
\brief Sets the threshold on the squared distance
|
void |
setHistory(int history)
\brief Sets the number of last frames that affect the background model
|
void |
setkNNSamples(int _nkNN)
\brief Sets the k in the kNN.
|
void |
setNSamples(int _nN)
\brief Sets the number of data samples in the background model.
|
void |
setShadowThreshold(double threshold)
\brief Sets the shadow threshold
|
void |
setShadowValue(int value)
\brief Sets the shadow value
|
apply, apply, apply, apply, apply, apply, getBackgroundImage, getBackgroundImage, getBackgroundImage
clear, empty, getDefaultName, position, read, save, save, write, write, write
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, toString, totalBytes, totalPhysicalBytes, withDeallocator, zero
public BackgroundSubtractorKNN(Pointer p)
Pointer.Pointer(Pointer)
.public int getHistory()
public void setHistory(int history)
public int getNSamples()
public void setNSamples(int _nN)
The model needs to be reinitalized to reserve memory.
public double getDist2Threshold()
The threshold on the squared distance between the pixel and the sample to decide whether a pixel is close to a data sample.
public void setDist2Threshold(double _dist2Threshold)
public int getkNNSamples()
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.
public void setkNNSamples(int _nkNN)
@Cast(value="bool") public boolean getDetectShadows()
If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorKNN for details.
public void setDetectShadows(@Cast(value="bool") boolean detectShadows)
public int getShadowValue()
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.
public void setShadowValue(int value)
public double getShadowThreshold()
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.
public void setShadowThreshold(double threshold)
Copyright © 2020. All rights reserved.