Skip to main content

Class: HandProcessor

@geenee/bodyprocessors.HandProcessor

Hand processor

Hand processor estimates 21 2D and 3D hand keypoints, it locates the hand region-of-interest (ROI) and predicts the pose keypoints providing smooth, stable and accurate pose estimation fot the hand. 2D pixel hand keypoints - 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, it has the same scale as X coordinate (normalized by image width). 2D points can be used for 2D overlays, math analyzes, or when using orthographic camera. 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 for 3D model overlays or virtual try-on. Rigged and skinned models can be rendered on top of the pose aligning skeleton/armature joints with 3D keypoints. 3D and 2D points are perfectly aligned, projections of 3D points coincide with 2D pixel coordinates within the perspective camera. Additionally hand processor detects wrist 2D position and direction. Wrist detection provides 3 lines in the screen coordinate space. Middle line defines 2D wrist base/center point and unit direction vector of the wrist. Two more lines define wrist edges by 2D screen points at the end of the wrist along transversal section through the base point and associated direction vectors. Wrist detection provides for virtual try-on of accessories like watches and bands.

Hierarchy

Constructors

constructor

new HandProcessor()

Constructor

Inherited from

Processor.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<ProcParams>

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): HandProcessor

Adds the listener function to the end of the listeners array

Type parameters

NameType
Eextends keyof ProcessorEvents

Parameters

NameTypeDescription
eventEThe name of the event
listenerProcessorEvents[E]The callback function

Returns

HandProcessor

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

NameType
Eextends keyof ProcessorEvents

Parameters

NameTypeDescription
eventEThe name of the event
...argsArgs<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 pose estimation.

Parameters

NameTypeDescription
paramsProcParamsProcessor parameters
size?SizeResolution of input video
ratio?numberAspect 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

NameType
Eextends keyof ProcessorEvents

Parameters

NameTypeDescription
eventEThe 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

NameType
Eextends keyof ProcessorEvents

Parameters

NameTypeDescription
eventEThe name of the event

Returns

Function[]

Copy of the listeners array

Inherited from

Processor.listeners


off

off<E>(event, listener): HandProcessor

Removes the listener from the listener array for the event

Type parameters

NameType
Eextends keyof ProcessorEvents

Parameters

NameTypeDescription
eventEThe name of the event
listenerProcessorEvents[E]The callback function

Returns

HandProcessor

This EventEmitter

Inherited from

Processor.off


on

on<E>(event, listener): HandProcessor

Adds the listener function to the event

Type parameters

NameType
Eextends keyof ProcessorEvents

Parameters

NameTypeDescription
eventEThe name of the event
listenerProcessorEvents[E]The callback function

Returns

HandProcessor

This EventEmitter

Inherited from

Processor.on


once

once<E>(event, listener): HandProcessor

Adds a one-time listener function for the event

Type parameters

NameType
Eextends keyof ProcessorEvents

Parameters

NameTypeDescription
eventEThe name of the event
listenerProcessorEvents[E]The callback function

Returns

HandProcessor

This EventEmitter

Inherited from

Processor.once


prependListener

prependListener<E>(event, listener): HandProcessor

Adds the listener function to the beginning of the listeners array

Type parameters

NameType
Eextends keyof ProcessorEvents

Parameters

NameTypeDescription
eventEThe name of the event
listenerProcessorEvents[E]The callback function

Returns

HandProcessor

This EventEmitter

Inherited from

Processor.prependListener


prependOnceListener

prependOnceListener<E>(event, listener): HandProcessor

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

Type parameters

NameType
Eextends keyof ProcessorEvents

Parameters

NameTypeDescription
eventEThe name of the event
listenerProcessorEvents[E]The callback function

Returns

HandProcessor

Inherited from

Processor.prependOnceListener


process

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

Process the image

Pose processor detects hand and predicts keypoints.

Parameters

NameTypeDescription
inputImageInputImage
timestamp?number-

Returns

Promise<HandResult>

Pose estimation or undefined

Overrides

Processor.process


rawListeners

rawListeners<E>(event): Function[]

Copy of the array of listeners for the event including wrappers

Type parameters

NameType
Eextends keyof ProcessorEvents

Parameters

NameTypeDescription
eventEThe name of the event

Returns

Function[]

Copy of the listeners array

Inherited from

Processor.rawListeners


removeAllListeners

removeAllListeners<E>(event?): HandProcessor

Removes all listeners, or those of the specified event

Type parameters

NameType
Eextends keyof ProcessorEvents

Parameters

NameTypeDescription
event?EThe name of the event

Returns

HandProcessor

This EventEmitter

Inherited from

Processor.removeAllListeners


removeListener

removeListener<E>(event, listener): HandProcessor

Removes the specified listener from the listener array

Type parameters

NameType
Eextends keyof ProcessorEvents

Parameters

NameTypeDescription
eventEThe name of the event
listenerProcessorEvents[E]The callback function

Returns

HandProcessor

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): HandProcessor

Sets maximum number of listeners per event

Parameters

NameTypeDescription
nnumberMaximum number of listeners

Returns

HandProcessor

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. Hand processor fixes FoV for more accurate hand alignment.

Parameters

NameTypeDescription
sizeSizeResolution of input video
ratio?numberAspect ration of input video

Returns

void

Overrides

Processor.setupVideo