Class cv::BackgroundSubtractor#

Base class for background/foreground segmentation. : View details

Collaboration diagram for cv::BackgroundSubtractor:

Public Member Functions#

Public Member Functions inherited from cv::Algorithm

Return

Name

Description

Algorithm()

~Algorithm()

void

clear()

Clears the algorithm state.

bool

empty()

Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read.

String

getDefaultName()

void

read(const FileNode & fn)

Reads algorithm parameters from a file storage.

void

save(const String & filename)

void

write(
    const Ptr< FileStorage > & fs,
    const String & name = String() )

void

write(FileStorage & fs)

Stores algorithm parameters in a file storage.

void

write(
    FileStorage & fs,
    const String & name )

Static Public Member Functions#

Static Public Member Functions inherited from cv::Algorithm

Return

Name

Description

static Ptr< _Tp >

load(
    const String & filename,
    const String & objname = String() )

Loads algorithm from the file.

static Ptr< _Tp >

loadFromString(
    const String & strModel,
    const String & objname = String() )

Loads algorithm from a String.

static Ptr< _Tp >

read(const FileNode & fn)

Reads algorithm from the file node.

Additional Inherited Members#

Protected Member Functions inherited from cv::Algorithm

Return

Name

Description

void

writeFormat(FileStorage & fs)

Detailed Description#

Base class for background/foreground segmentation. :

The class is only used to define the common interface for the whole family of background/foreground segmentation algorithms.

Member Function Documentation#

apply()#

void cv::BackgroundSubtractor::apply(
InputArray image,
InputArray knownForegroundMask,
OutputArray fgmask,
double learningRate = -1 )

Python:

cv.BackgroundSubtractor.apply(image[, fgmask[, learningRate]]) -> fgmask
cv.BackgroundSubtractor.apply(image, knownForegroundMask[, fgmask[, learningRate]]) -> fgmask

Computes a foreground mask with known foreground mask input.

Note

This method has a default virtual implementation that throws a “not impemented” error. Foreground masking may not be supported by all background subtractors.

Parameters

  • image — Next video frame. Floating point frame will be used without scaling and should be in range \([0,255]\).

  • fgmask — The output foreground mask as an 8-bit binary image.

  • knownForegroundMask — The mask for inputting already known foreground, allows model to ignore pixels.

  • learningRate — 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.

apply()#

void cv::BackgroundSubtractor::apply(
InputArray image,
OutputArray fgmask,
double learningRate = -1 )

Python:

cv.BackgroundSubtractor.apply(image[, fgmask[, learningRate]]) -> fgmask
cv.BackgroundSubtractor.apply(image, knownForegroundMask[, fgmask[, learningRate]]) -> fgmask

Computes a foreground mask.

Parameters

  • image — Next video frame.

  • fgmask — The output foreground mask as an 8-bit binary image.

  • learningRate — 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.

getBackgroundImage()#

void cv::BackgroundSubtractor::getBackgroundImage(OutputArray backgroundImage)

Python:

cv.BackgroundSubtractor.getBackgroundImage([, backgroundImage]) -> backgroundImage

Computes a background image.

Note

Sometimes the background image can be very blurry, as it contain the average background statistics.

Parameters

  • backgroundImage — The output background image.

Source file#

The documentation for this class was generated from the following file: