Skip to main content

Class: VideoPlugin<ResultT>

@geenee/armature.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.

Type parameters

NameTypeDescription
ResultTextends Object = Type of processing results

Hierarchy

  • Plugin<ResultT>

    VideoPlugin

Constructors

constructor

new VideoPlugin<ResultT>()

Constructor

Type parameters

NameType
ResultTextends Object =

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

NameTypeDescription
rendererRenderer<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

NameTypeDescription
rationumberAspect ration of input video
anglenumberVertical 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

NameTypeDescription
sizeSizeResolution 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

NameTypeDescription
resultResultTResults of video processing
streamHTMLCanvasElementCaptured video frame

Returns

Promise<void>

Promise resolving when update is finished

Inherited from

Plugin.update