View Source Evision.BackgroundSubtractorKNN (Evision v0.2.9)
Summary
Functions
Computes a foreground mask.
Computes a foreground mask.
Clears the algorithm state
Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read
Computes a background image.
Computes a background image.
getDefaultName
Returns the shadow detection flag
Returns the threshold on the squared distance between the pixel and the sample
Returns the number of last frames that affect the background model
Returns the number of neighbours, the k in the kNN.
Returns the number of data samples in the background model
Returns the shadow threshold
Returns the shadow value
Reads algorithm parameters from a file storage
save
Enables or disables shadow detection
Sets the threshold on the squared distance
Sets the number of last frames that affect the background model
Sets the k in the kNN. How many nearest neighbours need to match.
Sets the number of data samples in the background model.
Sets the shadow threshold
Sets the shadow value
Stores algorithm parameters in a file storage
write
Types
@type t() :: %Evision.BackgroundSubtractorKNN{ref: reference()}
Type that represents an BackgroundSubtractorKNN
struct.
ref.
reference()
The underlying erlang resource variable.
Functions
@spec apply(t(), Evision.Mat.maybe_mat_in()) :: Evision.Mat.t() | {:error, String.t()}
Computes a foreground mask.
Positional Arguments
self:
Evision.BackgroundSubtractorKNN.t()
image:
Evision.Mat
.Next video frame.
Keyword Arguments
learningRate:
double
.The value between 0 and 1 that indicates how fast the background model is learnt. Negative parameter value makes the algorithm to use some automatically chosen learning rate. 0 means that the background model is not updated at all, 1 means that the background model is completely reinitialized from the last frame.
Return
fgmask:
Evision.Mat.t()
.The output foreground mask as an 8-bit binary image.
Python prototype (for reference only):
apply(image[, fgmask[, learningRate]]) -> fgmask
@spec apply(t(), Evision.Mat.maybe_mat_in(), [{:learningRate, term()}] | nil) :: Evision.Mat.t() | {:error, String.t()}
Computes a foreground mask.
Positional Arguments
self:
Evision.BackgroundSubtractorKNN.t()
image:
Evision.Mat
.Next video frame.
Keyword Arguments
learningRate:
double
.The value between 0 and 1 that indicates how fast the background model is learnt. Negative parameter value makes the algorithm to use some automatically chosen learning rate. 0 means that the background model is not updated at all, 1 means that the background model is completely reinitialized from the last frame.
Return
fgmask:
Evision.Mat.t()
.The output foreground mask as an 8-bit binary image.
Python prototype (for reference only):
apply(image[, fgmask[, learningRate]]) -> fgmask
@spec clear(Keyword.t()) :: any() | {:error, String.t()}
@spec clear(t()) :: t() | {:error, String.t()}
Clears the algorithm state
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
Python prototype (for reference only):
clear() -> None
@spec empty(Keyword.t()) :: any() | {:error, String.t()}
@spec empty(t()) :: boolean() | {:error, String.t()}
Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
Return
- retval:
bool
Python prototype (for reference only):
empty() -> retval
@spec getBackgroundImage(Keyword.t()) :: any() | {:error, String.t()}
@spec getBackgroundImage(t()) :: Evision.Mat.t() | {:error, String.t()}
Computes a background image.
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
Return
backgroundImage:
Evision.Mat.t()
.The output background image.
Note: Sometimes the background image can be very blurry, as it contain the average background statistics.
Python prototype (for reference only):
getBackgroundImage([, backgroundImage]) -> backgroundImage
@spec getBackgroundImage(t(), [{atom(), term()}, ...] | nil) :: Evision.Mat.t() | {:error, String.t()}
Computes a background image.
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
Return
backgroundImage:
Evision.Mat.t()
.The output background image.
Note: Sometimes the background image can be very blurry, as it contain the average background statistics.
Python prototype (for reference only):
getBackgroundImage([, backgroundImage]) -> backgroundImage
@spec getDefaultName(Keyword.t()) :: any() | {:error, String.t()}
@spec getDefaultName(t()) :: binary() | {:error, String.t()}
getDefaultName
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
Return
- retval:
String
Returns the algorithm string identifier. This string is used as top level xml/yml node tag when the object is saved to a file or string.
Python prototype (for reference only):
getDefaultName() -> retval
@spec getDetectShadows(Keyword.t()) :: any() | {:error, String.t()}
@spec getDetectShadows(t()) :: boolean() | {:error, String.t()}
Returns the shadow detection flag
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
Return
- retval:
bool
If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorKNN for details.
Python prototype (for reference only):
getDetectShadows() -> retval
@spec getDist2Threshold(Keyword.t()) :: any() | {:error, String.t()}
@spec getDist2Threshold(t()) :: number() | {:error, String.t()}
Returns the threshold on the squared distance between the pixel and the sample
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
Return
- retval:
double
The threshold on the squared distance between the pixel and the sample to decide whether a pixel is close to a data sample.
Python prototype (for reference only):
getDist2Threshold() -> retval
@spec getHistory(Keyword.t()) :: any() | {:error, String.t()}
@spec getHistory(t()) :: integer() | {:error, String.t()}
Returns the number of last frames that affect the background model
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
Return
- retval:
integer()
Python prototype (for reference only):
getHistory() -> retval
@spec getkNNSamples(Keyword.t()) :: any() | {:error, String.t()}
@spec getkNNSamples(t()) :: integer() | {:error, String.t()}
Returns the number of neighbours, the k in the kNN.
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
Return
- retval:
integer()
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.
Python prototype (for reference only):
getkNNSamples() -> retval
@spec getNSamples(Keyword.t()) :: any() | {:error, String.t()}
@spec getNSamples(t()) :: integer() | {:error, String.t()}
Returns the number of data samples in the background model
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
Return
- retval:
integer()
Python prototype (for reference only):
getNSamples() -> retval
@spec getShadowThreshold(Keyword.t()) :: any() | {:error, String.t()}
@spec getShadowThreshold(t()) :: number() | {:error, String.t()}
Returns the shadow threshold
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
Return
- retval:
double
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.
Python prototype (for reference only):
getShadowThreshold() -> retval
@spec getShadowValue(Keyword.t()) :: any() | {:error, String.t()}
@spec getShadowValue(t()) :: integer() | {:error, String.t()}
Returns the shadow value
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
Return
- retval:
integer()
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.
Python prototype (for reference only):
getShadowValue() -> retval
@spec read(t(), Evision.FileNode.t()) :: t() | {:error, String.t()}
Reads algorithm parameters from a file storage
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
- func:
Evision.FileNode
Python prototype (for reference only):
read(fn) -> None
save
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
- filename:
String
Saves the algorithm to a file. In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs).
Python prototype (for reference only):
save(filename) -> None
Enables or disables shadow detection
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
- detectShadows:
bool
Python prototype (for reference only):
setDetectShadows(detectShadows) -> None
Sets the threshold on the squared distance
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
- dist2Threshold:
double
Python prototype (for reference only):
setDist2Threshold(_dist2Threshold) -> None
Sets the number of last frames that affect the background model
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
- history:
integer()
Python prototype (for reference only):
setHistory(history) -> None
Sets the k in the kNN. How many nearest neighbours need to match.
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
- nkNN:
integer()
Python prototype (for reference only):
setkNNSamples(_nkNN) -> None
Sets the number of data samples in the background model.
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
- nN:
integer()
The model needs to be reinitalized to reserve memory.
Python prototype (for reference only):
setNSamples(_nN) -> None
Sets the shadow threshold
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
- threshold:
double
Python prototype (for reference only):
setShadowThreshold(threshold) -> None
Sets the shadow value
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
- value:
integer()
Python prototype (for reference only):
setShadowValue(value) -> None
@spec write(t(), Evision.FileStorage.t()) :: t() | {:error, String.t()}
Stores algorithm parameters in a file storage
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
- fs:
Evision.FileStorage
Python prototype (for reference only):
write(fs) -> None
@spec write(t(), Evision.FileStorage.t(), binary()) :: t() | {:error, String.t()}
write
Positional Arguments
- self:
Evision.BackgroundSubtractorKNN.t()
- fs:
Evision.FileStorage
- name:
String
Has overloading in C++
Python prototype (for reference only):
write(fs, name) -> None