Skip to content

bgsegm_BackgroundSubtractorMOG

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

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

ARGUMENTSConstructor or factory
CLASSbgsegm_BackgroundSubtractorMOG
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.

Gaussian Mixture-based Background/Foreground Segmentation Algorithm.

The class implements the algorithm described in [KB2001] .

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 and skips known foreground in evaluation.

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 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.

knownForegroundMask

The mask for inputting already known foreground, allows model to ignore learning known pixels.

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.

getHistory

Return the history configured on this bgsegm_BackgroundSubtractorMOG object.

getHistory(): number;
Returns

The number result.

setHistory

Set the history used by this bgsegm_BackgroundSubtractorMOG object.

setHistory(nframes: number): void;
nframes

nframes argument (number).

getNMixtures

Return the nmixtures configured on this bgsegm_BackgroundSubtractorMOG object.

getNMixtures(): number;
Returns

The number result.

setNMixtures

Set the nmixtures used by this bgsegm_BackgroundSubtractorMOG object.

setNMixtures(nmix: number): void;
nmix

nmix argument (number).

getBackgroundRatio

Return the background ratio configured on this bgsegm_BackgroundSubtractorMOG object.

getBackgroundRatio(): number;
Returns

The number result.

setBackgroundRatio

Set the background ratio used by this bgsegm_BackgroundSubtractorMOG object.

setBackgroundRatio(backgroundRatio: number): void;
backgroundRatio

background ratio argument (number).

getNoiseSigma

Return the noise sigma configured on this bgsegm_BackgroundSubtractorMOG object.

getNoiseSigma(): number;
Returns

The number result.

setNoiseSigma

Set the noise sigma used by this bgsegm_BackgroundSubtractorMOG object.

setNoiseSigma(noiseSigma: number): void;
noiseSigma

noise sigma 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.