BackgroundSubtractor
import { BackgroundSubtractor } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Native object: release it with using or delete(). Factories can return null; check before calling methods. Inherits Algorithm.
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.
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;The this result.
apply
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;imageNext video frame.
fgmaskOutput destination, filled by the native operation. The output foreground mask as an 8-bit binary image.
learningRateThe 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 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;imageNext video frame. Floating point frame will be used without scaling and should be in range
[0,255].knownForegroundMaskThe mask for inputting already known foreground, allows model to ignore pixels.
fgmaskOutput destination, filled by the native operation. The output foreground mask as an 8-bit binary image.
learningRateThe 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
Computes a background image.
Note: Sometimes the background image can be very blurry, as it contain the average background statistics.
getBackgroundImage(backgroundImage: Mat): void;backgroundImageOutput destination, filled by the native operation. The output background image.
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.