Skip to content

HairProcessor

Hair segmentation mask processor

Hair processor estimates accurate & stable hair segmentation masks. Segmentation mask - monochrome image, where every pixel has value in range [0..1] denoting the probability of it being a foreground. Mask is provided for normalized rect region of the original image, it has a fixed size in pixels and should be scaled to image space. Optional temporal smoothing of a segmentation mask may be enabled. Estimated mask can be used for hair recoloring, color estimation, advanced occluder materials utilizing a mask, regional patchers.

new HairProcessor(): HairProcessor

Constructor

HairProcessor

Processor.constructor

cameraAngle: number

Camera vertical angle in radians

Processor.cameraAngle


cameraRatio: number

Camera aspect ratio

Processor.cameraRatio


optimalSize: number

Recommended maximum size of input

Processor.optimalSize


protected params: Partial<MaskParams>

Processor parameters

Processor.params


protected videoRatio: number

Aspect ratio of input video

Processor.videoRatio


protected videoSize: Size

Resolution of input video

Processor.videoSize

addListener<E>(event, listener): this

Adds the listener function to the end of the listeners array

E extends keyof ProcessorEvents

E

The name of the event

ProcessorEvents[E]

The callback function

this

This EventEmitter

Processor.addListener


dispose(): void

Dispose processor object

Releases resources and instances allocated by processor. Processor object cannot be used after calling dispose().

void

Processor.dispose


emit<E>(event, …args): boolean

Synchronously calls each of the listeners registered for the event

E extends keyof ProcessorEvents

E

The name of the event

Args<ProcessorEvents[E]>

Arguments passed to the listeners

boolean

True if the event had listeners, False otherwise

Processor.emit


eventNames(): (string | symbol)[]

List of emitter’s events

(string | symbol)[]

List of emitter’s events

Processor.eventNames


getMaxListeners(): number

Maximum number of listeners per event

number

Maximum number of listeners per event

Processor.getMaxListeners


init(params, size?, ratio?): Promise<boolean>

Initialize processor

Prepares all resources required for face mesh tracking.

MaskParams

Processor parameters

Size

Resolution of input video

number

Aspect ration of input video

Promise<boolean>

Status of initialization

Processor.init


listenerCount<E>(event): number

The number of listeners listening to the event

E extends keyof ProcessorEvents

E

The name of the event

number

Number of listeners

Processor.listenerCount


listeners<E>(event): Function[]

Copy of the array of listeners for the event

E extends keyof ProcessorEvents

E

The name of the event

Function[]

Copy of the listeners array

Processor.listeners


off<E>(event, listener): this

Removes the listener from the listener array for the event

E extends keyof ProcessorEvents

E

The name of the event

ProcessorEvents[E]

The callback function

this

This EventEmitter

Processor.off


on<E>(event, listener): this

Adds the listener function to the event

E extends keyof ProcessorEvents

E

The name of the event

ProcessorEvents[E]

The callback function

this

This EventEmitter

Processor.on


once<E>(event, listener): this

Adds a one-time listener function for the event

E extends keyof ProcessorEvents

E

The name of the event

ProcessorEvents[E]

The callback function

this

This EventEmitter

Processor.once


prependListener<E>(event, listener): this

Adds the listener function to the beginning of the listeners array

E extends keyof ProcessorEvents

E

The name of the event

ProcessorEvents[E]

The callback function

this

This EventEmitter

Processor.prependListener


prependOnceListener<E>(event, listener): this

Adds a one-time listener function to the beginning of the listeners array

E extends keyof ProcessorEvents

E

The name of the event

ProcessorEvents[E]

The callback function

this

Processor.prependOnceListener


process(input, timestamp?): Promise<MaskResult>

Process the image

Mask processor evaluates and tracks segmentation masks.

ImageInput

Image

number

Image timestamp

Promise<MaskResult>

Segmentation masks

Processor.process


rawListeners<E>(event): Function[]

Copy of the array of listeners for the event including wrappers

E extends keyof ProcessorEvents

E

The name of the event

Function[]

Copy of the listeners array

Processor.rawListeners


removeAllListeners<E>(event?): this

Removes all listeners, or those of the specified event

E extends keyof ProcessorEvents

E

The name of the event

this

This EventEmitter

Processor.removeAllListeners


removeListener<E>(event, listener): this

Removes the specified listener from the listener array

E extends keyof ProcessorEvents

E

The name of the event

ProcessorEvents[E]

The callback function

this

This EventEmitter

Processor.removeListener


reset(): void

Reset processor

Resets all processing instances to the initial state.

void

Processor.reset


setMaxListeners(n): this

Sets maximum number of listeners per event

number

Maximum number of listeners

this

This EventEmitter

Processor.setMaxListeners


setupVideo(size, ratio?): void

Set resolution of the input video

Could be overridden to adjust processing pipeline.

Size

Resolution of input video

number

Aspect ration of input video

void

Processor.setupVideo