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.

ResultT extends object = { }

Type of processing results

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

Constructor

VideoPlugin<ResultT>

Plugin.constructor

loaded: boolean = false

Loaded state

Plugin.loaded


ordinal: number = PluginOrdinal.Render

Ordinal number

Plugin.ordinal


protected optional renderer: Renderer<ResultT>

Renderer loaded the plugin

Plugin.renderer


protected optional videoCtx: CanvasRenderingContext2D

Drawing context of video canvas layer

dispose(): void

Dispose video plugin

void

Plugin.dispose


load(renderer): Promise<void>

Initialize plugin

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

Renderer<ResultT>

Renderer this plugin is attached to

Promise<void>

Promise resolving when initialization is finished

Plugin.load


setupCamera(ratio, angle): void

Set camera parameters

Could be overridden to adjust plugin’s pipeline.

number

Aspect ration of input video

number

Vertical field of view in radians

void

Plugin.setupCamera


setupVideo(size): void

Set video size

Could be overridden to adjust plugin’s pipeline.

Size

Resolution of input video

void

Plugin.setupVideo


unload(): void

Reset plugin

Releases all resources allocated in load(). Deletes the reference to 2d canvas context.

void

Plugin.unload


update(result, stream): Promise<void>

Update

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

ResultT

Results of video processing

HTMLCanvasElement

Captured video frame

Promise<void>

Promise resolving when update is finished

Plugin.update