Skip to content

bgsegm_BackgroundSubtractorGMG

bgsegmclassOpenCV 5.0.0
import { bgsegm_BackgroundSubtractorGMG } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSConstructor or factory
CLASSbgsegm_BackgroundSubtractorGMG
RETURN TYPEOwned native handle
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Native object: release it with using or delete(). Factories can return null; check before calling methods. Inherits bgsegm_BackgroundSubtractor.

Background Subtractor module based on the algorithm given in [Gold2012] .

Takes a series of images and returns a sequence of mask (8UC1) images of the same size, where 255 indicates Foreground and 0 represents Background. This class implements an algorithm described in "Visual Tracking of Human Visitors under Variable-Lighting Conditions for a Responsive Audio Art Installation," A. Godbehere, A. Matsukawa, K. Goldberg, American Control Conference, Montreal, June 2012.

Constructors and members

clone

Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.

clone(): this;
Returns

The this result.

apply

BackgroundSubtractor interface Computes a foreground mask.

apply(image: Mat, fgmask: Mat, learningRate: number): void;
2 available overloads
apply(image: Mat, fgmask: Mat): void;
apply(image: Mat, fgmask: Mat, learningRate: number): void;
image

Next video frame of type CV_8UC(n),CV_8SC(n),CV_16UC(n),CV_16SC(n),CV_32SC(n),CV_32FC(n),CV_64FC(n), where n is 1,2,3,4.

fgmask

Output destination, filled by the native operation. 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.

apply1

Computes a foreground mask with known foreground mask input.

Note: This method has a default virtual implementation that throws a "not implemented" error. Foreground masking may not be supported by all background subtractors.

apply1(image: Mat, knownForegroundMask: Mat, fgmask: Mat, learningRate: number): void;
2 available overloads
apply1(image: Mat, knownForegroundMask: Mat, fgmask: Mat): void;
apply1(image: Mat, knownForegroundMask: Mat, fgmask: Mat, learningRate: number): void;
image

Next video frame.

knownForegroundMask

The mask for inputting already known foreground.

fgmask

Output destination, filled by the native operation. 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

Return the background image configured on this bgsegm_BackgroundSubtractorGMG object.

getBackgroundImage(backgroundImage: Mat): void;
backgroundImage

Output destination, filled by the native operation. background image argument (Mat).

getMaxFeatures

Returns total number of distinct colors to maintain in histogram.

getMaxFeatures(): number;
Returns

The number result.

setMaxFeatures

Sets total number of distinct colors to maintain in histogram.

setMaxFeatures(maxFeatures: number): void;
maxFeatures

max features argument (number).

getDefaultLearningRate

Returns the learning rate of the algorithm.

It lies between 0.0 and 1.0. It determines how quickly features are "forgotten" from
histograms.
getDefaultLearningRate(): number;
Returns

The number result.

setDefaultLearningRate

Sets the learning rate of the algorithm.

setDefaultLearningRate(lr: number): void;
lr

lr argument (number).

getNumFrames

Returns the number of frames used to initialize background model.

getNumFrames(): number;
Returns

The number result.

setNumFrames

Sets the number of frames used to initialize background model.

setNumFrames(nframes: number): void;
nframes

nframes argument (number).

getQuantizationLevels

Returns the parameter used for quantization of color-space.

It is the number of discrete levels in each channel to be used in histograms.
getQuantizationLevels(): number;
Returns

The number result.

setQuantizationLevels

Sets the parameter used for quantization of color-space

setQuantizationLevels(nlevels: number): void;
nlevels

nlevels argument (number).

getBackgroundPrior

Returns the prior probability that each individual pixel is a background pixel.

getBackgroundPrior(): number;
Returns

The number result.

setBackgroundPrior

Sets the prior probability that each individual pixel is a background pixel.

setBackgroundPrior(bgprior: number): void;
bgprior

bgprior argument (number).

getSmoothingRadius

Returns the kernel radius used for morphological operations

getSmoothingRadius(): number;
Returns

The number result.

setSmoothingRadius

Sets the kernel radius used for morphological operations

setSmoothingRadius(radius: number): void;
radius

radius argument (number).

getDecisionThreshold

Returns the value of decision threshold.

Decision value is the value above which pixel is determined to be FG.
getDecisionThreshold(): number;
Returns

The number result.

setDecisionThreshold

Sets the value of decision threshold.

setDecisionThreshold(thresh: number): void;
thresh

thresh argument (number).

getUpdateBackgroundModel

Returns the status of background model update

getUpdateBackgroundModel(): boolean;
Returns

The boolean result.

setUpdateBackgroundModel

Sets the status of background model update

setUpdateBackgroundModel(update: boolean): void;
update

update argument (boolean).

getMinVal

Returns the minimum value taken on by pixels in image sequence. Usually 0.

getMinVal(): number;
Returns

The number result.

setMinVal

Sets the minimum value taken on by pixels in image sequence.

setMinVal(val: number): void;
val

val argument (number).

getMaxVal

Returns the maximum value taken on by pixels in image sequence. e.g. 1.0 or 255.

getMaxVal(): number;
Returns

The number result.

setMaxVal

Sets the maximum value taken on by pixels in image sequence.

setMaxVal(val: number): void;
val

val argument (number).

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.