Class: BodyPatchPlugin
@geenee/bodyrenderers-babylon.BodyPatchPlugin
Body patch plugin
Plugin patches (inpaints/erases) foreground region of image defined by body segmentation mask from PoseProcessor. It can be used in avatar virtual try to remove parts of a user's body that stick out (not covered). Evaluation of body segmentation must be enabled in init() method enabling mask flag.
Hierarchy
ShaderPlugin
<PoseResult
>↳
BodyPatchPlugin
Constructors
constructor
• new BodyPatchPlugin()
Constructor
Overrides
ShaderPlugin<PoseResult\>.constructor
Properties
dilationShader
• Protected
Optional
dilationShader: DilationShader
Image dilation shader
fragSrc
• Protected
Optional
fragSrc: string
Inherited from
ShaderPlugin.fragSrc
inputs
• Protected
Optional
inputs: string
[]
Inherited from
ShaderPlugin.inputs
loaded
• loaded: boolean
Loaded state
Inherited from
ShaderPlugin.loaded
maskTexture
• Protected
Optional
maskTexture: ImageTexture
Segmentation mask texture
renderer
• Protected
Optional
renderer: Renderer
<PoseResult
>
Renderer loaded the plugin
Inherited from
ShaderPlugin.renderer
shader
• Protected
Optional
shader: ShaderProgram
Rendering shader
Inherited from
ShaderPlugin.shader
size
• Protected
size: Size
Image size
Inherited from
ShaderPlugin.size
uniforms
• Protected
Optional
uniforms: Object
Index signature
▪ [key: string
]: UniformType
Inherited from
ShaderPlugin.uniforms
vertSrc
• Protected
Optional
vertSrc: string
Inherited from
ShaderPlugin.vertSrc
Methods
dispose
▸ dispose(): void
Dispose video plugin
Returns
void
Inherited from
ShaderPlugin.dispose
load
▸ load(renderer
): Promise
<void
>
Initialize plugin
Initializes resources required for shader effect.
Parameters
Name | Type | Description |
---|---|---|
renderer | Renderer <PoseResult > | Renderer this plugin is attached to |
Returns
Promise
<void
>
Promise resolving when initialization is finished
Overrides
ShaderPlugin.load
process
▸ process(result
, input
): boolean
Process the image
Patches (inpaints) foreground image pixels according to provided segmentation mask.
Parameters
Name | Type | Description |
---|---|---|
result | PoseResult | Results of video processing |
input | WebGLTexture | Current image texture |
Returns
boolean
True on success, false otherwise
Overrides
ShaderPlugin.process
setupVideo
▸ setupVideo(size
): void
Set video size
Adjusts shader and texture to a new size.
Parameters
Name | Type |
---|---|
size | Size |
Returns
void
Inherited from
ShaderPlugin.setupVideo
unload
▸ unload(): void
Reset plugin
Releases all resources and instances created in load().
Returns
void
Overrides
ShaderPlugin.unload
update
▸ update(result
, stream
): Promise
<void
>
Update the image
Main method implementing webgl shader effect or filter. ShaderRenderer has current image texture that will be rendered. ShaderPlugin uses current texture as input and writes results to ShaderPlugin#output. ShaderPlugin#output becomes new current texture of ShaderRenderer. This way all ShaderPlugins attached to renderer organize a chain of effects applied on top of each other. Method process() implements shader effect itself, it's intended to be overridden by effect authors.
Parameters
Name | Type | Description |
---|---|---|
result | PoseResult | Results of video processing |
stream | HTMLCanvasElement | Captured video frame |
Returns
Promise
<void
>
Promise resolving when update is finished
Inherited from
ShaderPlugin.update