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
Section titled “Extends”Plugin
<ResultT
>
Type Parameters
Section titled “Type Parameters”ResultT
Section titled “ResultT”ResultT
extends object
= { }
Type of processing results
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new VideoPlugin<
ResultT
>():VideoPlugin
<ResultT
>
Constructor
Returns
Section titled “Returns”VideoPlugin
<ResultT
>
Overrides
Section titled “Overrides”Properties
Section titled “Properties”loaded
Section titled “loaded”loaded:
boolean
=false
Loaded state
Inherited from
Section titled “Inherited from”ordinal
Section titled “ordinal”ordinal:
number
=PluginOrdinal.Render
Ordinal number
Inherited from
Section titled “Inherited from”renderer?
Section titled “renderer?”
protected
optional
renderer:Renderer
<ResultT
>
Renderer loaded the plugin
Inherited from
Section titled “Inherited from”videoCtx?
Section titled “videoCtx?”
protected
optional
videoCtx:CanvasRenderingContext2D
Drawing context of video canvas layer
Methods
Section titled “Methods”dispose()
Section titled “dispose()”dispose():
void
Dispose video plugin
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”load()
Section titled “load()”load(
renderer
):Promise
<void
>
Initialize plugin
Initializes everything required for image drawing. Acquires video canvas 2d context of the renderer.
Parameters
Section titled “Parameters”renderer
Section titled “renderer”Renderer
<ResultT
>
Renderer this plugin is attached to
Returns
Section titled “Returns”Promise
<void
>
Promise resolving when initialization is finished
Overrides
Section titled “Overrides”setupCamera()
Section titled “setupCamera()”setupCamera(
ratio
,angle
):void
Set camera parameters
Could be overridden to adjust plugin’s pipeline.
Parameters
Section titled “Parameters”number
Aspect ration of input video
number
Vertical field of view in radians
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setupVideo()
Section titled “setupVideo()”setupVideo(
size
):void
Set video size
Could be overridden to adjust plugin’s pipeline.
Parameters
Section titled “Parameters”Resolution of input video
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”unload()
Section titled “unload()”unload():
void
Reset plugin
Releases all resources allocated in load(). Deletes the reference to 2d canvas context.
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”update()
Section titled “update()”update(
result
,stream
):Promise
<void
>
Update
Main method implementing the logic of the plugin. Overridden by derived classes for particular task.
Parameters
Section titled “Parameters”result
Section titled “result”ResultT
Results of video processing
stream
Section titled “stream”HTMLCanvasElement
Captured video frame
Returns
Section titled “Returns”Promise
<void
>
Promise resolving when update is finished