Leaper Vision Toolkit
中文 / English 2.x
Public Member Functions | Properties
ILBGSubtract Interface Reference

This interface provide functionalities of background subtraction for consistent or slowly changing environment. More...

Inheritance diagram for ILBGSubtract:
ILObject LBGSubtract

Public Member Functions

LPVErrorCode Apply (ILImage *img, ILImage *fgMask, BOOL doUpdateBGModel)
 
LPVErrorCode UpdateBGModel (ILImage *img)
 
- Public Member Functions inherited from ILObject
ILObjectCopy ()
 
LPVErrorCode Load (LString filename)
 
void Reset ()
 
LPVErrorCode Save (LString filename)
 
BOOL Valid ()
 

Properties

double GenerateThreshold [get, set]
 The generation threshold used to determine the complexity of the background model. If the foreground and the background is very different, you should use a larger threshold which result in more robust background model; otherwise if they are very similar, you should use a smaller threshold to generate a more sensitive background model.
It should be a positive value. By default, it's set to 3.
Change this value will reset the background model.
 
int HistoryMaxCount [get, set]
 The max count of the history images which affect the background model. The larger number result in the smaller default learning rate and the slower the background update.
It should be a positive integer. By default, it's set to 500.
Change this value will reset the background model.
 
double LearningRate [get, set]
 The learning rate is used to control how much the background model should learn from the new coming frame.
It's in range 0 ~ 1, bigger value means faster learning. 0 means not learning at all, 1 means completely reinitialized. By default, it's set to -1 to let the algorithm to automatically chose the rate, based on the historical data and current model.
 
double VarianceThreshold [get, set]
 The variance threshold used to determine whether the current pixel is foreground or background. If the background changes obviously, the threshold should be set higher, while the detection sensitivity decreases.
It should be a positive value. By default, it's set to 25.
Change this value will reset the background model.
 

Detailed Description

This interface provide functionalities of background subtraction for consistent or slowly changing environment.

Background subtraction is a widely-used technique for detecting moving or pop-up objects in the static scene.

We model the background for each pixel using the history images. Then given the present image, every pixel is compared with the background model and classified as either foreground or background. The background model should also be updated continuously on the fly, which is controllable by a proper learning rate.

To use this interface, you should create a LBGSubtract object.

Example Code

Member Function Documentation

◆ Apply()

LPVErrorCode Apply ( ILImage img,
ILImage fgMask,
BOOL  doUpdateBGModel 
)

Apply the background model to the input image, report the foreground mask.

Parameters
[in]imgThe input image.
[out]fgMask Output the foreground mask. White pixels are foreground.
[in]doUpdateBGModelWhether to update the background model using the current new frame.
Return values
errorReturn error code if anything is wrong.

◆ UpdateBGModel()

LPVErrorCode UpdateBGModel ( ILImage img)

Update the background model using the input image.

Parameters
[in]imgThe input image.
Return values
errorReturn error code if anything is wrong.