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

### Hierarchy

- Human

## Index

### Constructors

- constructor

### Properties

- classes
- config
- draw
- faceTriangulation
- faceUVMap
- image
- models
- perf
- state
- sysinfo
- tf
- version

### Methods

- detect
- enhance
- load
- match
- similarity
- warmup

## Constructors

### constructor

- new Human(userConfig?: Object | Config): Human

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

  - @param userConfig: Config

  #### Parameters

  - ##### userConfig: Object | Config = {}

  #### Returns Human

## Properties

### classes

classes: { body: __module | __module; emotion: __module; facemesh: __module; faceres: __module; hand: __module; nanodet: __module }

Internal: Currently loaded classes

#### Type declaration

- ##### body: __module | __module

- ##### emotion: __module

- ##### facemesh: __module

- ##### faceres: __module

- ##### hand: __module

- ##### nanodet: __module

### config

config: Config

Current configuration

- Details: Config

### draw

draw: { all: (inCanvas: HTMLCanvasElement, result: any, drawOptions?: DrawOptions) => Promise<void>; body: (inCanvas: HTMLCanvasElement, result: any[], drawOptions?: DrawOptions) => Promise<void>; canvas: (inCanvas: HTMLCanvasElement, outCanvas: HTMLCanvasElement) => Promise<void>; face: (inCanvas: HTMLCanvasElement, result: any[], drawOptions?: DrawOptions) => Promise<void>; gesture: (inCanvas: HTMLCanvasElement, result: any[], drawOptions?: DrawOptions) => Promise<void>; hand: (inCanvas: HTMLCanvasElement, result: any[], drawOptions?: DrawOptions) => Promise<void>; options: DrawOptions }

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

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

#### Type declaration

- ##### all: (inCanvas: HTMLCanvasElement, result: any, drawOptions?: DrawOptions) => Promise<void>

  - - (inCanvas: HTMLCanvasElement, result: any, drawOptions?: DrawOptions): Promise<void>

    - #### Parameters

      - ##### inCanvas: HTMLCanvasElement

      - ##### result: any

      - ##### Optional drawOptions: DrawOptions

      #### Returns Promise<void>

- ##### body: (inCanvas: HTMLCanvasElement, result: any[], drawOptions?: DrawOptions) => Promise<void>

  - - (inCanvas: HTMLCanvasElement, result: any[], drawOptions?: DrawOptions): Promise<void>

    - #### Parameters

      - ##### inCanvas: HTMLCanvasElement

      - ##### result: any[]

      - ##### Optional drawOptions: DrawOptions

      #### Returns Promise<void>

- ##### canvas: (inCanvas: HTMLCanvasElement, outCanvas: HTMLCanvasElement) => Promise<void>

  - - (inCanvas: HTMLCanvasElement, outCanvas: HTMLCanvasElement): Promise<void>

    - #### Parameters

      - ##### inCanvas: HTMLCanvasElement

      - ##### outCanvas: HTMLCanvasElement

      #### Returns Promise<void>

- ##### face: (inCanvas: HTMLCanvasElement, result: any[], drawOptions?: DrawOptions) => Promise<void>

  - - (inCanvas: HTMLCanvasElement, result: any[], drawOptions?: DrawOptions): Promise<void>

    - #### Parameters

      - ##### inCanvas: HTMLCanvasElement

      - ##### result: any[]

      - ##### Optional drawOptions: DrawOptions

      #### Returns Promise<void>

- ##### gesture: (inCanvas: HTMLCanvasElement, result: any[], drawOptions?: DrawOptions) => Promise<void>

  - - (inCanvas: HTMLCanvasElement, result: any[], drawOptions?: DrawOptions): Promise<void>

    - #### Parameters

      - ##### inCanvas: HTMLCanvasElement

      - ##### result: any[]

      - ##### Optional drawOptions: DrawOptions

      #### Returns Promise<void>

- ##### hand: (inCanvas: HTMLCanvasElement, result: any[], drawOptions?: DrawOptions) => Promise<void>

  - - (inCanvas: HTMLCanvasElement, result: any[], drawOptions?: DrawOptions): Promise<void>

    - #### Parameters

      - ##### inCanvas: HTMLCanvasElement

      - ##### result: any[]

      - ##### Optional drawOptions: DrawOptions

      #### Returns Promise<void>

- ##### options: DrawOptions

### faceTriangulation

faceTriangulation: number[]

Face triangualtion array of 468 points, used for triangle references between points

### faceUVMap

faceUVMap: number[][]

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

### image

image: { canvas: null | HTMLCanvasElement | OffscreenCanvas; tensor: null | typeof __class }

Internal: Instance of current image being processed

#### Type declaration

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

- ##### tensor: null | typeof __class

### models

models: { age: null | Object; blazepose: null | Object; efficientpose: null | Object; embedding: null | Object; emotion: null | Object; face: null | [Object, Object, Object]; faceres: null | Object; gender: null | Object; handpose: null | [Object, Object]; iris: null | Object; nanodet: null | Object; posenet: null | Object }

Internal: Currently loaded models

#### Type declaration

- ##### age: null | Object

- ##### blazepose: null | Object

- ##### efficientpose: null | Object

- ##### embedding: null | Object

- ##### emotion: null | Object

- ##### face: null | [Object, Object, Object]

- ##### faceres: null | Object

- ##### gender: null | Object

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

- ##### iris: null | Object

- ##### nanodet: null | Object

- ##### posenet: null | Object

### perf

perf: any

Performance object that contains values for all recently performed operations

### state

state: string

Current state of Human library

- Can be polled to determine operations that are currently executed

### sysinfo

sysinfo: { agent: string; platform: string }

Platform and agent information detected by Human

#### Type declaration

- ##### agent: string

- ##### platform: string

### tf

tf: __module

Internal: Instance of TensorFlow/JS used by Human

- Can be embedded or externally provided

### version

version: string

Current version of Human library in semver format

## Methods

### detect

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

- Main detection method

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

  #### Parameters

  - ##### input: Input

  - ##### userConfig: Object | Config = {}

  #### Returns Promise<Error | Result>

### enhance

- enhance(input: typeof __class): null | typeof __class

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

  #### Parameters

  - ##### input: typeof __class

    Tensor as provided in human.result.face[n].tensor

  #### Returns null | typeof __class

  Tensor

### load

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

- Load method preloads all configured models on-demand

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

  #### Parameters

  - ##### userConfig: Object | 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 }

- 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

### similarity

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

- 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

### warmup

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

- Warmup metho pre-initializes all models for faster inference

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

  #### Parameters

  - ##### userConfig: Object | Config = {}

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