Skip to content

VideoPlugin

Generic video plugin

VideoPlugin is a specialization of a Plugin for VideoRenderer. Usually they perform simple 2D drawing tasks on a video canvas (for example, simplest face effects or adding debug information / graphics). VideoPlugin gets access to 2d canvas of VideoRenderer in load() and draws on this canvas directly in update(), on top of video frame using provided processing data.

Extends

Type Parameters

ResultT extends object = object

Type of processing results

Constructors

new VideoPlugin()

new VideoPlugin<ResultT>(): VideoPlugin<ResultT>

Constructor

Returns

VideoPlugin<ResultT>

Overrides

Plugin.constructor

Properties

loaded

loaded: boolean = false

Loaded state

Inherited from

Plugin.loaded


ordinal

ordinal: number = PluginOrdinal.Render

Ordinal number

Inherited from

Plugin.ordinal


renderer?

protected optional renderer: Renderer<ResultT>

Renderer loaded the plugin

Inherited from

Plugin.renderer


videoCtx?

protected optional videoCtx: CanvasRenderingContext2D

Drawing context of video canvas layer

Methods

dispose()

dispose(): void

Dispose video plugin

Returns

void

Inherited from

Plugin.dispose


load()

load(renderer): Promise<void>

Initialize plugin

Initializes everything required for image drawing. Acquires video canvas 2d context of the renderer.

Parameters

renderer: Renderer<ResultT>

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 allocated in load(). Deletes the reference to 2d canvas context.

Returns

void

Overrides

Plugin.unload


update()

update(result, stream): Promise<void>

Update

Main method implementing the logic of the plugin. Overridden by derived classes for particular task.

Parameters

result: ResultT

Results of video processing

stream: HTMLCanvasElement

Captured video frame

Returns

Promise<void>

Promise resolving when update is finished

Inherited from

Plugin.update