MaskBinaryPlugin
Binarization plugin for segmentation mask
Applies a mask binarization agains provided threshold. Plugin depends on MaskUploadPlugin that must be attached to the renderer to upload mask buffer in texture. It may be combined with other mask post-processing plugins. Order in which operation on mask are applied corresponds to the order in which plugins are attached to the renderer.
Extends
Section titled “Extends”MaskProcessPlugin
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MaskBinaryPlugin(
thresh
,size?
):MaskBinaryPlugin
Constructor
Parameters
Section titled “Parameters”thresh
Section titled “thresh”number
= 0.55
Foreground threshold
Size of segmentation mask
Returns
Section titled “Returns”MaskBinaryPlugin
Overrides
Section titled “Overrides”MaskProcessPlugin.constructor
Properties
Section titled “Properties”fragSrc?
Section titled “fragSrc?”
protected
optional
fragSrc:string
Code of fragment shader (copy shader by default)
Inherited from
Section titled “Inherited from”MaskProcessPlugin.fragSrc
inputs
Section titled “inputs”
protected
inputs:string
[]
Shader texiwure inputs (names of sampler uniforms)
Inherited from
Section titled “Inherited from”MaskProcessPlugin.inputs
loaded
Section titled “loaded”loaded:
boolean
Loaded state
Inherited from
Section titled “Inherited from”MaskProcessPlugin.loaded
ordinal
Section titled “ordinal”ordinal:
number
Ordinal number
Inherited from
Section titled “Inherited from”MaskProcessPlugin.ordinal
renderer?
Section titled “renderer?”
protected
optional
renderer:Renderer
<SegmentationResult
>
Renderer loaded the plugin
Inherited from
Section titled “Inherited from”MaskProcessPlugin.renderer
shader?
Section titled “shader?”
protected
optional
shader:ShaderProgram
Processing shader
Inherited from
Section titled “Inherited from”MaskProcessPlugin.shader
protected
size:Size
Size of segmentation mask texture
Inherited from
Section titled “Inherited from”MaskProcessPlugin.size
uniforms
Section titled “uniforms”
protected
uniforms:object
={}
Shader uniforms as name-type map object
Index Signature
Section titled “Index Signature”[key
: string
]: UniformType
Inherited from
Section titled “Inherited from”MaskProcessPlugin.uniforms
vertSrc?
Section titled “vertSrc?”
protected
optional
vertSrc:string
Vertex shader source (copy shader by default)
Inherited from
Section titled “Inherited from”MaskProcessPlugin.vertSrc
Methods
Section titled “Methods”dispose()
Section titled “dispose()”dispose():
void
Dispose video plugin
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”MaskProcessPlugin.dispose
load()
Section titled “load()”load(
renderer
):Promise
<void
>
Initialize plugin
Initializes mask processing shader.
Parameters
Section titled “Parameters”renderer
Section titled “renderer”Renderer this plugin is attached to
Returns
Section titled “Returns”Promise
<void
>
Promise resolving when initialization is finished
Inherited from
Section titled “Inherited from”MaskProcessPlugin.load
process()
Section titled “process()”process(
result
):void
Process the segmentation mask
Main method implementing shader processing on the mask. It’s called by update() and could be overridden to add custom logic. Internally process() updates input mask object passed from tracking result, thus replacing mask in-place. Default implementation applies processing shader and updates segmentatin texture with its output.
Parameters
Section titled “Parameters”result
Section titled “result”Segmentation mask
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”MaskProcessPlugin.process
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”MaskProcessPlugin.setupCamera
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”MaskProcessPlugin.setupVideo
unload()
Section titled “unload()”unload():
void
Reset plugin
Releases all resources initialized in load().
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”MaskProcessPlugin.unload
update()
Section titled “update()”update(
result
,stream
):Promise
<void
>
Update segmentation masks
Updates segmentation mask applying processing shader.
The mask is updated in place within tracking result
object, therefore next plugins in the pipeline will
access updated mask and mask processings can be chained.
Parameters
Section titled “Parameters”result
Section titled “result”Results of video processing
stream
Section titled “stream”HTMLCanvasElement
Captured video frame
Returns
Section titled “Returns”Promise
<void
>
Inherited from
Section titled “Inherited from”MaskProcessPlugin.update