Human library main class

All methods and properties are available only as members of Human class

- Configuration object definition: Config
- Results object definition: Result
- Possible inputs: Input

param

  Config

### Hierarchy

- Human

## Index

### Constructors

- constructor

### Properties

- config
- draw
- env
- events
- faceTriangulation
- faceUVMap
- initial
- models
- performance
- process
- result
- state
- tf
- version

### Methods

- detect
- enhance
- image
- load
- match
- next
- segmentation
- similarity
- warmup

## Constructors

### constructor

- new Human(userConfig?: Partial<Config>): Human

- - Defined in human.ts:162

  Creates instance of Human library that is futher used for all operations

  #### Parameters

  - ##### Optional userConfig: Partial<Config>

  #### Returns Human

## Properties

### config

config: Config

- Defined in human.ts:81

Current configuration

- Details: Config

### draw

draw: { all: any; body: any; canvas: any; face: any; gesture: any; hand: any; object: any; options: DrawOptions; person: any }

- Defined in human.ts:116

Draw helper classes that can draw detected objects on canvas using specified draw

- options: DrawOptions global settings for all draw operations, can be overriden for each draw method
- face: draw detected faces
- body: draw detected people and body parts
- hand: draw detected hands and hand parts
- canvas: draw this.processed canvas which is a this.processed copy of the input
- all: meta-function that performs: canvas, face, body, hand

#### Type declaration

- ##### all: any

- ##### body: any

- ##### canvas: any

- ##### face: any

- ##### gesture: any

- ##### hand: any

- ##### object: any

- ##### options: DrawOptions

- ##### person: any

### env

env: Env

- Defined in human.ts:105

Object containing environment information used for diagnostics

### events

events: EventTarget

- Defined in human.ts:145

Container for events dispatched by Human

Possible events:

- `create`: triggered when Human object is instantiated
- `load`: triggered when models are loaded (explicitly or on-demand)
- `image`: triggered when input image is this.processed
- `result`: triggered when detection is complete
- `warmup`: triggered when warmup is complete

### faceTriangulation

faceTriangulation: number[]

- Defined in human.ts:147

Reference face triangualtion array of 468 points, used for triangle references between points

### faceUVMap

faceUVMap: number[][]

- Defined in human.ts:149

Refernce UV map of 468 values, used for 3D mapping of the face mesh

### initial

initial: boolean

- Defined in human.ts:155

### models

models: { age: null | GraphModel; blazepose: null | GraphModel; centernet: null | GraphModel; efficientpose: null | GraphModel; embedding: null | GraphModel; emotion: null | GraphModel; face: null | [unknown, null | GraphModel, null | GraphModel]; faceres: null | GraphModel; gender: null | GraphModel; handpose: null | [null | GraphModel, null | GraphModel]; movenet: null | GraphModel; nanodet: null | GraphModel; posenet: null | GraphModel; segmentation: null | GraphModel }

- Defined in human.ts:119

internal:

  Currently loaded models

#### Type declaration

- ##### age: null | GraphModel

- ##### blazepose: null | GraphModel

- ##### centernet: null | GraphModel

- ##### efficientpose: null | GraphModel

- ##### embedding: null | GraphModel

- ##### emotion: null | GraphModel

- ##### face: null | [unknown, null | GraphModel, null | GraphModel]

- ##### faceres: null | GraphModel

- ##### gender: null | GraphModel

- ##### handpose: null | [null | GraphModel, null | GraphModel]

- ##### movenet: null | GraphModel

- ##### nanodet: null | GraphModel

- ##### posenet: null | GraphModel

- ##### segmentation: null | GraphModel

### performance

performance: Record<string, number>

- Defined in human.ts:151

Performance object that contains values for all recently performed operations

### process

process: { canvas: null | HTMLCanvasElement | OffscreenCanvas; tensor: null | Tensor<Rank> }

- Defined in human.ts:95

currenty processed image tensor and canvas

#### Type declaration

- ##### canvas: null | HTMLCanvasElement | OffscreenCanvas

- ##### tensor: null | Tensor<Rank>

### result

result: Result

- Defined in human.ts:86

Last known result of detect run

- Can be accessed anytime after initial detection

### state

state: string

- Defined in human.ts:92

Current state of Human library

- Can be polled to determine operations that are currently executed
- Progresses through: 'config', 'check', 'backend', 'load', 'run:', 'idle'

### tf

tf: any

- Defined in human.ts:100

internal:

  Instance of TensorFlow/JS used by Human

  - Can be embedded or externally provided

### version

version: string

- Defined in human.ts:76

Current version of Human library in semver format

## Methods

### detect

- detect(input: Input, userConfig?: Partial<Config>): Promise<Error | Result>

- - Defined in human.ts:367

  Main detection method

  - Analyze configuration: Config
  - Pre-this.process input: Input
  - Run inference for all configured models
  - Process and return result: Result

  #### Parameters

  - ##### input: Input

  - ##### Optional userConfig: Partial<Config>

  #### Returns Promise<Error | Result>

  result: Result

### enhance

- enhance(input: Tensor<Rank>): null | Tensor<Rank>

- - Defined in human.ts:281

  Enhance method performs additional enhacements to face image previously detected for futher this.processing

  #### Parameters

  - ##### input: Tensor<Rank>

  #### Returns null | Tensor<Rank>

  Tensor

### image

- image(input: Input): { canvas: HTMLCanvasElement | OffscreenCanvas; tensor: null | Tensor<Rank> }

- - Defined in human.ts:249

  Process input as return canvas and tensor

  #### Parameters

  - ##### input: Input

  #### Returns { canvas: HTMLCanvasElement | OffscreenCanvas; tensor: null | Tensor<Rank> }

  - ##### canvas: HTMLCanvasElement | OffscreenCanvas

  - ##### tensor: null | Tensor<Rank>

### load

- load(userConfig?: Partial<Config>): Promise<void>

- - Defined in human.ts:300

  Load method preloads all configured models on-demand

  - Not explicitly required as any required model is load implicitly on it's first run

  #### Parameters

  - ##### Optional userConfig: Partial<Config>

  #### Returns Promise<void>

### match

- match(faceEmbedding: number[], db: { embedding: number[]; name: string; source: string }[], threshold?: number): { embedding: number[]; name: string; similarity: number; source: string }

- - Defined in human.ts:292

  Math method find best match between provided face descriptor and predefined database of known descriptors

  #### Parameters

  - ##### faceEmbedding: number[]

  - ##### db: { embedding: number[]; name: string; source: string }[]

  - ##### threshold: number = 0

  #### Returns { embedding: number[]; name: string; similarity: number; source: string }

  best match

  - ##### embedding: number[]

  - ##### name: string

  - ##### similarity: number

  - ##### source: string

### next

- next(result?: Result): Result

- - Defined in human.ts:343

  Runs interpolation using last known result and returns smoothened result Interpolation is based on time since last known result so can be called independently

  #### Parameters

  - ##### result: Result = ...

  #### Returns Result

  result: Result

### segmentation

- segmentation(input: Input, background?: Input): Promise<null | HTMLCanvasElement | OffscreenCanvas>

- - Defined in human.ts:272

  Segmentation method takes any input and returns this.processed canvas with body segmentation Optional parameter background is used to fill the background with specific input Segmentation is not triggered as part of detect this.process

  #### Parameters

  - ##### input: Input

  - ##### Optional background: Input

  #### Returns Promise<null | HTMLCanvasElement | OffscreenCanvas>

  Canvas

### similarity

- similarity(embedding1: number[], embedding2: number[]): number

- - Defined in human.ts:259

  Simmilarity method calculates simmilarity between two provided face descriptors (face embeddings)

  - Calculation is based on normalized Minkowski distance between

  #### Parameters

  - ##### embedding1: number[]

  - ##### embedding2: number[]

  #### Returns number

  similarity: number

### warmup

- warmup(userConfig?: Partial<Config>): Promise<Result | { error: any }>

- - Defined in human.ts:353

  Warmup method pre-initializes all configured models for faster inference

  - can take significant time on startup
  - only used for `webgl` and `humangl` backends

  #### Parameters

  - ##### Optional userConfig: Partial<Config>

  #### Returns Promise<Result | { error: any }>

  result: Result