Class: FaceProcessor
@geenee/bodyprocessors.FaceProcessor
Face mesh processor
Face mesh processor estimates 3D face landmarks, it detects and tracks face mesh providing smooth, stable and accurate results. Processor evaluates 2D pixel and 3D metric points as well as face pose (translation+rotation+scale) aligning reference face model. 2D pixel face landmarks - points in the screen coordinate space. X and Y coordinates are normalized screen coordinates (scaled by width and height of the input image), while the Z coordinate is depth within orthographic projection space. These points can be used for 2D face filters or when using orthographic projection. 3D metric points - points within 3D space of perspective camera located at the space origin and pointed in the negative direction of the Z-axis. These points can be used to apply texture face mask. 3D and 2D points are perfectly aligned, projections of 3D points coincide with 2D pixel coordinates within the perspective camera. Face pose - transformation matrix (translation+rotation+scale) aligning reference face 3D model with the measured 3D face mesh. Applying this transformation one can align 3D object with the detected face. If the model's initial position is aligned with the reference face, relative transformation will be preserved.
Hierarchy
Processor
<FaceResult
,FaceParams
>↳
FaceProcessor
Constructors
constructor
• new FaceProcessor()
Constructor
Inherited from
Processor<FaceResult, FaceParams>.constructor
Properties
cameraAngle
• cameraAngle: number
Camera vertical angle in radians
Inherited from
Processor.cameraAngle
cameraAngleBase
• Readonly
cameraAngleBase: number
View angle of perspective camera along smallest side
cameraRatio
• cameraRatio: number
Camera aspect ratio
Inherited from
Processor.cameraRatio
optimalSize
• optimalSize: number
Recommended maximum size of input
Inherited from
Processor.optimalSize
params
• Protected
params: Partial
<FaceParams
>
Processor parameters
Inherited from
Processor.params
videoRatio
• Protected
videoRatio: number
Aspect ratio of input video
Inherited from
Processor.videoRatio
videoSize
• Protected
videoSize: Size
Resolution of input video
Inherited from
Processor.videoSize
Methods
addListener
▸ addListener<E
>(event
, listener
): FaceProcessor
Adds the listener function to the end of the listeners array
Type parameters
Name | Type |
---|---|
E | extends keyof ProcessorEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | ProcessorEvents [E ] | The callback function |
Returns
This EventEmitter
Inherited from
Processor.addListener
dispose
▸ dispose(): void
Dispose processor object
Releases resources and instances allocated by processor. Processor object cannot be used after calling dispose().
Returns
void
Overrides
Processor.dispose
emit
▸ emit<E
>(event
, ...args
): boolean
Synchronously calls each of the listeners registered for the event
Type parameters
Name | Type |
---|---|
E | extends keyof ProcessorEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
...args | Args <ProcessorEvents [E ]> | Arguments passed to the listeners |
Returns
boolean
True if the event had listeners, False otherwise
Inherited from
Processor.emit
eventNames
▸ eventNames(): (string
| symbol
)[]
List of emitter's events
Returns
(string
| symbol
)[]
List of emitter's events
Inherited from
Processor.eventNames
getMaxListeners
▸ getMaxListeners(): number
Maximum number of listeners per event
Returns
number
Maximum number of listeners per event
Inherited from
Processor.getMaxListeners
init
▸ init(params
, size?
, ratio?
): Promise
<boolean
>
Initialize processor
Prepares all resources required for face mesh tracking.
Parameters
Name | Type | Description |
---|---|---|
params | FaceParams | Processor parameters |
size? | Size | Resolution of input video |
ratio? | number | Aspect ration of input video |
Returns
Promise
<boolean
>
Status of initialization
Overrides
Processor.init
listenerCount
▸ listenerCount<E
>(event
): number
The number of listeners listening to the event
Type parameters
Name | Type |
---|---|
E | extends keyof ProcessorEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
Returns
number
Number of listeners
Inherited from
Processor.listenerCount
listeners
▸ listeners<E
>(event
): Function
[]
Copy of the array of listeners for the event
Type parameters
Name | Type |
---|---|
E | extends keyof ProcessorEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
Returns
Function
[]
Copy of the listeners array
Inherited from
Processor.listeners
off
▸ off<E
>(event
, listener
): FaceProcessor
Removes the listener from the listener array for the event
Type parameters
Name | Type |
---|---|
E | extends keyof ProcessorEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | ProcessorEvents [E ] | The callback function |
Returns
This EventEmitter
Inherited from
Processor.off
on
▸ on<E
>(event
, listener
): FaceProcessor
Adds the listener function to the event
Type parameters
Name | Type |
---|---|
E | extends keyof ProcessorEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | ProcessorEvents [E ] | The callback function |
Returns
This EventEmitter
Inherited from
Processor.on
once
▸ once<E
>(event
, listener
): FaceProcessor
Adds a one-time listener function for the event
Type parameters
Name | Type |
---|---|
E | extends keyof ProcessorEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | ProcessorEvents [E ] | The callback function |
Returns
This EventEmitter
Inherited from
Processor.once
prependListener
▸ prependListener<E
>(event
, listener
): FaceProcessor
Adds the listener function to the beginning of the listeners array
Type parameters
Name | Type |
---|---|
E | extends keyof ProcessorEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | ProcessorEvents [E ] | The callback function |
Returns
This EventEmitter
Inherited from
Processor.prependListener
prependOnceListener
▸ prependOnceListener<E
>(event
, listener
): FaceProcessor
Adds a one-time listener function to the beginning of the listeners array
Type parameters
Name | Type |
---|---|
E | extends keyof ProcessorEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | ProcessorEvents [E ] | The callback function |
Returns
Inherited from
Processor.prependOnceListener
process
▸ process(input
, timestamp?
): Promise
<undefined
| FaceResult
>
Process the image
Face mesh processor detects and tracks faces.
Parameters
Name | Type | Description |
---|---|---|
input | ImageInput | Image |
timestamp? | number | - |
Returns
Promise
<undefined
| FaceResult
>
Face mesh or undefined
Overrides
Processor.process
rawListeners
▸ rawListeners<E
>(event
): Function
[]
Copy of the array of listeners for the event including wrappers
Type parameters
Name | Type |
---|---|
E | extends keyof ProcessorEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
Returns
Function
[]
Copy of the listeners array
Inherited from
Processor.rawListeners
removeAllListeners
▸ removeAllListeners<E
>(event?
): FaceProcessor
Removes all listeners, or those of the specified event
Type parameters
Name | Type |
---|---|
E | extends keyof ProcessorEvents |
Parameters
Name | Type | Description |
---|---|---|
event? | E | The name of the event |
Returns
This EventEmitter
Inherited from
Processor.removeAllListeners
removeListener
▸ removeListener<E
>(event
, listener
): FaceProcessor
Removes the specified listener from the listener array
Type parameters
Name | Type |
---|---|
E | extends keyof ProcessorEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | ProcessorEvents [E ] | The callback function |
Returns
This EventEmitter
Inherited from
Processor.removeListener
reset
▸ reset(): void
Reset processor
Resets all processing instances to the initial state.
Returns
void
Overrides
Processor.reset
setMaxListeners
▸ setMaxListeners(n
): FaceProcessor
Sets maximum number of listeners per event
Parameters
Name | Type | Description |
---|---|---|
n | number | Maximum number of listeners |
Returns
This EventEmitter
Inherited from
Processor.setMaxListeners
setupVideo
▸ setupVideo(size
, ratio?
): void
Set resolution of the input video
Defines view angle according to resolution and aspect ratio. Face mesh processor fixes FoV for more accurate estimation.
Parameters
Name | Type | Description |
---|---|---|
size | Size | Resolution of input video |
ratio? | number | Aspect ration of input video |
Returns
void
Overrides
Processor.setupVideo