Skip to main content

BackgroundFilter

@auvious/media-tools / Exports / BackgroundFilter

Class: BackgroundFilter

Generic for input

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new BackgroundFilter()

Properties

anchor

Private anchor: number = 0


backgroundConfig

Private backgroundConfig: BackgroundConfig


canvas

Private canvas: CanvasElement


canvasStream

Private Optional canvasStream: null | MediaStream = null


counter

Private counter: number = 0


events

events: Events<IBackgroundFilterEventMap>


frameDelay

Private frameDelay: number = 0


image

Private image: null | HTMLImageElement = null


modelFileName

Private modelFileName: string = fullModelFileName


name

name: string = "background-filter.video"

distinct effect name

Implementation of

IMediaEffect.name


pipeline

Private pipeline: null | RenderingPipeline = null


postProcessingConfig

Private postProcessingConfig: PostProcessingConfig


rendering

Private rendering: boolean = false

control the render loop


segmentationConfig

Private segmentationConfig: SegmentationConfig


streamIn

Private Optional streamIn: MediaStream


streamOut

Private streamOut: null | MediaStream = null


tflite

tflite: null | TFLite = null


useWebGL

Private useWebGL: boolean = false


video

Private video: HTMLVideoElement

Methods

frameEnd

Private frameEnd(): void

Returns

void


genOutput

Private genOutput(): void

Returns

void


load

load(options): Promise<boolean>

load and initialize models

Parameters

NameTypeDescription
optionsObjectassetsPath: absolute url where wasm and models reside
options.assetsPathstring-
options.image?HTMLImageElementonfail triggers if fails to use image
options.lite?boolean-
options.useWebgl?boolean-

Returns

Promise<boolean>

boolean


loadCanvasPipeline

loadCanvasPipeline(): void

Returns

void


loadModel

Private loadModel(assetsPath): Promise<void>

Parameters

NameType
assetsPathstring

Returns

Promise<void>


loadPipeline

Private loadPipeline(): Promise<boolean>

Returns

Promise<boolean>


loadWasm

Private loadWasm(assetsPath): Promise<boolean>

Parameters

NameType
assetsPathstring

Returns

Promise<boolean>


loadWebGLPipeline

Private loadWebGLPipeline(): void

Returns

void


onOutput

onOutput(callback): () => void

listen for output changes

Parameters

NameType
callback(stream: MediaStream) => void

Returns

fn

▸ (): void

Returns

void

Implementation of

IMediaEffect.onOutput


onUnload

onUnload(callback): () => void

listen for effect removal

Parameters

NameType
callback() => void

Returns

fn

▸ (): void

Returns

void

Implementation of

IMediaEffect.onUnload


pause

pause(): void

Returns

void


play

play(): null | MediaStream

plays only if input stream is set

Returns

null | MediaStream


render

Private render(): Promise<void>

Returns

Promise<void>


setImage

setImage(image): Promise<boolean>

Set a background image

Parameters

NameType
imageHTMLImageElement

Returns

Promise<boolean>

boolean if succeeded, also triggers onfail event if not


setInput

setInput(stream?): void

Parameters

NameType
stream?MediaStream

Returns

void

Implementation of

IMediaEffect.setInput


unload

unload(): void

Returns

void


unsetImage

unsetImage(): void

Returns

void


whenImageReady

Private whenImageReady(image): Promise<null | Error>

Parameters

NameType
imageHTMLImageElement

Returns

Promise<null | Error>