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
Name | Type | Description |
---|---|---|
ResultT | extends Object = | Type of processing results |
Hierarchy
-
Plugin
<ResultT
>↳
VideoPlugin
Constructors
constructor
• new VideoPlugin<ResultT
>()
Constructor
Type parameters
Name | Type |
---|---|
ResultT | extends Object = |
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
result | ResultT | Results of video processing |
stream | HTMLCanvasElement | Captured video frame |
Returns
Promise
<void
>
Promise resolving when update is finished