Skip to main content

Class: Plugin<ResultT>

@geenee/armature.Plugin

Generic renderer plugin

Plugin can be attached to a PluginRenderer instance. Usually they perform simple tasks that can be separated from bigger app context into atomic building blocks, for example control object on a scene to follow (be attached to) user's head, apply image effect (smoothing, beautification), recognize gestures or poses, notify about state changes or perform other kinds of transformations, pre/post-processing, or analyzes with a 3D scene, video stream or raw data from a Processor. Plugin is a abstraction level to single out ready-made helpers that can be reused as atomic building blocks of an application. Plugins are very similar to Renderer and also should implement two basic methods load() and update(). Renderer initializes a plugin calling load() and providing itself as argument, plugin in turn remembers renderer it's attached to and gets access to required resources of the renderer, for example 2d or webgl context of a canvas or reference to a 3d scene. In update() method plugins implement actual logic given processing results. Renderer applies attached plugins in order defined by their ordinal number. In some cases priority of plugins execution is important, e.g. there can be a plugin that filters results of pose processing by some constraint, let's say it passes only poses where upper body is in the field of view and asks a user to step back for better virtual try-on experience, this plugin should update poses before plugin that renders virtual apparel.

Type parameters

NameTypeDescription
ResultTextends Object = Type of processing results

Hierarchy

Constructors

constructor

new Plugin<ResultT>()

Type parameters

NameType
ResultTextends Object =

Properties

loaded

loaded: boolean = false

Loaded state


ordinal

ordinal: number = PluginOrdinal.Render

Ordinal number


renderer

Protected Optional renderer: Renderer<ResultT>

Renderer loaded the plugin

Methods

dispose

dispose(): void

Dispose video plugin

Returns

void


load

load(renderer): Promise<void>

Initialize plugin

Initializes resources/instances needed by plugin. Overridden by derived classes for particular task.

Parameters

NameTypeDescription
rendererRenderer<ResultT>Renderer this plugin is attached to

Returns

Promise<void>

Promise resolving when initialization is finished


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


setupVideo

setupVideo(size): void

Set video size

Could be overridden to adjust plugin's pipeline.

Parameters

NameTypeDescription
sizeSizeResolution of input video

Returns

void


unload

unload(): void

Reset plugin

Releases all resources/instances created in load(). Overridden by derived classes for particular task.

Returns

void


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