BackgroundSubtractorKNN
Objective-C
@interface BackgroundSubtractorKNN : BackgroundSubtractor
Swift
class BackgroundSubtractorKNN : 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.
Member of Video
-
Returns the shadow detection flag
If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorKNN for details.
Declaration
Objective-C
- (BOOL)getDetectShadows;
Swift
func getDetectShadows() -> Bool
-
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.
Declaration
Objective-C
- (double)getDist2Threshold;
Swift
func getDist2Threshold() -> Double
-
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.
Declaration
Objective-C
- (double)getShadowThreshold;
Swift
func getShadowThreshold() -> Double
-
Returns the number of last frames that affect the background model
Declaration
Objective-C
- (int)getHistory;
Swift
func getHistory() -> Int32
-
Returns the number of data samples in the background model
Declaration
Objective-C
- (int)getNSamples;
Swift
func getNSamples() -> Int32
-
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.
Declaration
Objective-C
- (int)getShadowValue;
Swift
func getShadowValue() -> Int32
-
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
Objective-C
- (int)getkNNSamples;
Swift
func getkNNSamples() -> Int32
-
Enables or disables shadow detection
Declaration
Objective-C
- (void)setDetectShadows:(BOOL)detectShadows;
Swift
func setDetectShadows(detectShadows: Bool)
-
Sets the threshold on the squared distance
Declaration
Objective-C
- (void)setDist2Threshold:(double)_dist2Threshold;
Swift
func setDist2Threshold(_dist2Threshold: Double)
-
Sets the number of last frames that affect the background model
Declaration
Objective-C
- (void)setHistory:(int)history;
Swift
func setHistory(history: Int32)
-
Sets the number of data samples in the background model.
The model needs to be reinitalized to reserve memory.
Declaration
Objective-C
- (void)setNSamples:(int)_nN;
Swift
func setNSamples(_nN: Int32)
-
Sets the shadow threshold
Declaration
Objective-C
- (void)setShadowThreshold:(double)threshold;
Swift
func setShadowThreshold(threshold: Double)
-
Sets the shadow value
Declaration
Objective-C
- (void)setShadowValue:(int)value;
Swift
func setShadowValue(value: Int32)
-
Sets the k in the kNN. How many nearest neighbours need to match.
Declaration
Objective-C
- (void)setkNNSamples:(int)_nkNN;
Swift
func setkNNSamples(_nkNN: Int32)