Skip to main content

Class: BodyPatchHDPlugin

@geenee/bodyrenderers-common.BodyPatchHDPlugin

Hight resolution body patch plugin

Advanced version of BodyPatchPlugin that uses high resolution segmentation mask evaluated by BodyMaskHDPlugin. High resolution segmentation significantly increases accuracy of patching and reduces patch region. BodyMaskHDPlugin must be added to ShaderRenderer pipeline.

Hierarchy

Constructors

constructor

new BodyPatchHDPlugin(dilationR?)

Constructor

Parameters

NameTypeDefault valueDescription
dilationRnumber2Radius of mask dilation

Inherited from

BodyPatchPlugin.constructor

Properties

dilationR

Protected dilationR: number = 2

Radius of mask dilation

Inherited from

BodyPatchPlugin.dilationR


dilationShader

Protected Optional dilationShader: DilationShader

Image dilation shader

Inherited from

BodyPatchPlugin.dilationShader


fragSrc

Protected Optional fragSrc: string

Code of fragment shader (copy shader by default)

Inherited from

BodyPatchPlugin.fragSrc


inputs

Protected Optional inputs: string[]

Shader texture inputs (names of sampler uniforms)

Inherited from

BodyPatchPlugin.inputs


loaded

loaded: boolean

Loaded state

Inherited from

BodyPatchPlugin.loaded


ordinal

ordinal: number

Ordinal number

Inherited from

BodyPatchPlugin.ordinal


renderer

Protected Optional renderer: Renderer<PoseResult>

Renderer loaded the plugin

Inherited from

BodyPatchPlugin.renderer


shader

Protected Optional shader: ShaderProgram

Rendering shader

Inherited from

BodyPatchPlugin.shader


size

Protected size: Size

Image size

Inherited from

BodyPatchPlugin.size


uniforms

Protected Optional uniforms: Object

Shader uniforms as name-type map object

Index signature

▪ [key: string]: UniformType

Inherited from

BodyPatchPlugin.uniforms


vertSrc

Protected Optional vertSrc: string

Vertex shader source (copy shader by default)

Inherited from

BodyPatchPlugin.vertSrc

Methods

dispose

dispose(): void

Dispose video plugin

Returns

void

Inherited from

BodyPatchPlugin.dispose


load

load(renderer): Promise<void>

Initialize plugin

Initializes resources required for HD body patching.

Parameters

NameTypeDescription
rendererRenderer<PoseResult>Renderer this plugin is attached to

Returns

Promise<void>

Promise resolving when initialization is finished

Overrides

BodyPatchPlugin.load


process

process(result, input): Promise<boolean>

Process the image

Patches (inpaints) foreground pixels according to evaluated high resolution segmentation mask.

Parameters

NameTypeDescription
resultPoseResultResults of video processing
inputWebGLTextureCurrent image texture

Returns

Promise<boolean>

True on success, false otherwise

Overrides

BodyPatchPlugin.process


setupCamera

setupCamera(ratio, angle): void

Set camera parameters

Could be overridden to adjust plugin's pipeline.

Parameters

NameTypeDescription
rationumberAspect ration of input video
anglenumberVertical field of view in radians

Returns

void

Inherited from

BodyPatchPlugin.setupCamera


setupVideo

setupVideo(size): void

Set video size

Adjusts shader and texture to a new size.

Parameters

NameTypeDescription
sizeSizeResolution of input video

Returns

void

Inherited from

BodyPatchPlugin.setupVideo


unload

unload(): void

Reset plugin

Releases all resources and instances created in load().

Returns

void

Inherited from

BodyPatchPlugin.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

NameTypeDescription
resultPoseResultResults of video processing
streamHTMLCanvasElementCaptured video frame

Returns

Promise<void>

Promise resolving when update is finished

Inherited from

BodyPatchPlugin.update