Skip to content

createBackgroundSubtractorKNN

Motion and trackingfunctionOpenCV 5.0.0
import { createBackgroundSubtractorKNN } from '@banou/opencv-wasm'

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

Creates KNN Background Subtractor

createBackgroundSubtractorKNN(history: number, dist2Threshold: number, detectShadows: boolean): BackgroundSubtractorKNN | null;
4 available overloads
createBackgroundSubtractorKNN(): BackgroundSubtractorKNN | null;
createBackgroundSubtractorKNN(history: number): BackgroundSubtractorKNN | null;
createBackgroundSubtractorKNN(history: number, dist2Threshold: number): BackgroundSubtractorKNN | null;
createBackgroundSubtractorKNN(history: number, dist2Threshold: number, detectShadows: boolean): BackgroundSubtractorKNN | null;
history

Length of the history.

dist2Threshold

Threshold on the squared distance between the pixel and the sample to decide whether a pixel is close to that sample. This parameter does not affect the background update.

detectShadows

If true, the algorithm will detect shadows and mark them. It decreases the speed a bit, so if you do not need this feature, set the parameter to false.

Returns

The BackgroundSubtractorKNN | null result.

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.