Skip to content

MaskStepPlugin

Smooth binarization plugin for segmentation mask

Performs mask binarization with smooth transition between 0 and 1 applying sigmoid function within threshold range. Plugin depends on MaskUploadPlugin that must be attached to the renderer to upload mask buffer in texture. It may be combined with other mask post-processing plugins. Order in which operation on mask are applied corresponds to the order in which plugins are attached to the renderer.

Extends

Constructors

new MaskStepPlugin()

new MaskStepPlugin(edge0, edge1, size): MaskStepPlugin

Constructor

Parameters

edge0: number = 0.25

Background threshold

edge1: number = 0.75

Foreground threshold

size: Size = ...

Size of segmentation mask

Returns

MaskStepPlugin

Overrides

Plugin.constructor

Properties

edge0

protected edge0: number = 0.25

Background threshold


edge1

protected edge1: number = 0.75

Foreground threshold


loaded

loaded: boolean

Loaded state

Inherited from

Plugin.loaded


ordinal

ordinal: number

Ordinal number

Inherited from

Plugin.ordinal


renderer?

protected optional renderer: Renderer<SegmentationResult>

Renderer loaded the plugin

Inherited from

Plugin.renderer


shader?

protected optional shader: ShaderProgram

Smooth step shader


size

protected size: Size

Size of segmentation mask

Methods

dispose()

dispose(): void

Dispose video plugin

Returns

void

Inherited from

Plugin.dispose


load()

load(renderer): Promise<void>

Initialize plugin

Initializes binarization shader program.

Parameters

renderer: Renderer<SegmentationResult>

Renderer this plugin is attached to

Returns

Promise<void>

Promise resolving when initialization is finished

Overrides

Plugin.load


setupCamera()

setupCamera(ratio, angle): void

Set camera parameters

Could be overridden to adjust plugin’s pipeline.

Parameters

ratio: number

Aspect ration of input video

angle: number

Vertical field of view in radians

Returns

void

Inherited from

Plugin.setupCamera


setupVideo()

setupVideo(size): void

Set video size

Could be overridden to adjust plugin’s pipeline.

Parameters

size: Size

Resolution of input video

Returns

void

Inherited from

Plugin.setupVideo


unload()

unload(): void

Reset plugin

Releases all resources initialized in load().

Returns

void

Overrides

Plugin.unload


update()

update(result, stream): Promise<void>

Update segmentation masks

Updates segmentation mask applying binarization op. Replaces maskTex of tracks with the updated mask.

Parameters

result: SegmentationResult

Results of video processing

stream: HTMLCanvasElement

Captured video frame

Returns

Promise<void>

Overrides

Plugin.update