Skip to content

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.

ResultT extends object = { }

Type of processing results

new Plugin<ResultT>(): Plugin<ResultT>

Plugin<ResultT>

loaded: boolean = false

Loaded state


ordinal: number = PluginOrdinal.Render

Ordinal number


protected optional renderer: Renderer<ResultT>

Renderer loaded the plugin

dispose(): void

Dispose video plugin

void


load(renderer): Promise<void>

Initialize plugin

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

Renderer<ResultT>

Renderer this plugin is attached to

Promise<void>

Promise resolving when initialization is finished


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


setupVideo(size): void

Set video size

Could be overridden to adjust plugin’s pipeline.

Size

Resolution of input video

void


unload(): void

Reset plugin

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

void


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