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
Plugin
<ResultT
>
Type Parameters
• ResultT extends object
= object
Type of processing results
Constructors
new VideoPlugin()
new VideoPlugin<
ResultT
>():VideoPlugin
<ResultT
>
Constructor
Returns
VideoPlugin
<ResultT
>
Overrides
Properties
loaded
loaded:
boolean
=false
Loaded state
Inherited from
ordinal
ordinal:
number
=PluginOrdinal.Render
Ordinal number
Inherited from
renderer?
protected
optional
renderer:Renderer
<ResultT
>
Renderer loaded the plugin
Inherited from
videoCtx?
protected
optional
videoCtx:CanvasRenderingContext2D
Drawing context of video canvas layer
Methods
dispose()
dispose():
void
Dispose video plugin
Returns
void
Inherited from
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
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
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
unload()
unload():
void
Reset plugin
Releases all resources allocated in load(). Deletes the reference to 2d canvas context.
Returns
void
Overrides
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