MaskMorphPlugin
Morphological operation plugin for segmentation mask
Performs a morphological operation on a segmentation mask. The most basic morphological ops are dilation and erosion. Dilation adds pixels to the boundaries of objects in an image, while erosion removes pixels on object boundaries. Value of the output pixel is maximum value of all pixels in the neighbourhood for dilation, and minimum for erosion. Radius of a square neighbourhood is a plugin’s parameter. Positive radius provides dilation while negative - erosion. Plugin depends on MaskUploadPlugin that must be attached to the renderer to upload mask buffer in texture. One may utilize MaskUpscalePlugin providing higher resolution segmentation mask that significantly increases mask’s accuracy. Plugin may be combined with other mask post-processing plugins. Order in which operation on mask are applied is defined by order of plugins’ attachment.
Extends
Constructors
new MaskMorphPlugin()
new MaskMorphPlugin(
radius
,size
):MaskMorphPlugin
Constructor
Parameters
• radius: number
= 1
Morphological operation radius
• size: Size
= ...
Size of segmentation mask
Returns
Overrides
Properties
loaded
loaded:
boolean
Loaded state
Inherited from
ordinal
ordinal:
number
Ordinal number
Inherited from
radius
protected
radius:number
=1
Morphological operation radius
renderer?
protected
optional
renderer:Renderer
<SegmentationResult
>
Renderer loaded the plugin
Inherited from
shader?
protected
optional
shader:DilationShader
|ErosionShader
Dilation or erosion shader
size
protected
size:Size
Size of segmentation mask
Methods
dispose()
dispose():
void
Dispose video plugin
Returns
void
Inherited from
load()
load(
renderer
):Promise
<void
>
Initialize plugin
Initializes dilation or erosion shader program.
Parameters
• renderer: Renderer
<SegmentationResult
>
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 initialized in load().
Returns
void
Overrides
update()
update(
result
,stream
):Promise
<void
>
Update segmentation masks
Updates segmentation mask applying morphological op.
Replaces maskTex
of tracks with the updated mask.
Parameters
• result: SegmentationResult
Results of video processing
• stream: HTMLCanvasElement
Captured video frame
Returns
Promise
<void
>