Skip to content

bgsegm_BackgroundSubtractorCNT

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

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

ARGUMENTSConstructor or factory
CLASSbgsegm_BackgroundSubtractorCNT
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 subtraction based on counting.

About as fast as MOG2 on a high end system. More than twice faster than MOG2 on cheap hardware (benchmarked on Raspberry Pi3).

%Algorithm by Sagi Zeevi ( https://github.com/sagi-z/BackgroundSubtractorCNT )

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

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

image argument (Mat).

fgmask

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

learningRate

learning rate argument (number).

apply1

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.

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

getBackgroundImage(backgroundImage: Mat): void;
backgroundImage

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

getMinPixelStability

Returns number of frames with same pixel color to consider stable.

getMinPixelStability(): number;
Returns

The number result.

setMinPixelStability

Sets the number of frames with same pixel color to consider stable.

setMinPixelStability(value: number): void;
value

value argument (number).

getMaxPixelStability

Returns maximum allowed credit for a pixel in history.

getMaxPixelStability(): number;
Returns

The number result.

setMaxPixelStability

Sets the maximum allowed credit for a pixel in history.

setMaxPixelStability(value: number): void;
value

value argument (number).

getUseHistory

Returns if we're giving a pixel credit for being stable for a long time.

getUseHistory(): boolean;
Returns

The boolean result.

setUseHistory

Sets if we're giving a pixel credit for being stable for a long time.

setUseHistory(value: boolean): void;
value

value argument (boolean).

getIsParallel

Returns if we're parallelizing the algorithm.

getIsParallel(): boolean;
Returns

The boolean result.

setIsParallel

Sets if we're parallelizing the algorithm.

setIsParallel(value: boolean): void;
value

value argument (boolean).

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.