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?: Config | Record<string, unknown>): Human

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

  - @param userConfig: Config

  #### Parameters

  - ##### userConfig: Config | Record<string, unknown> = {}

  #### Returns Human

## Properties

### classes

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

Internal: Currently loaded classes

#### Type declaration

- ##### body: __module | __module

- ##### centernet: __module

- ##### emotion: __module

- ##### facemesh: __module

- ##### faceres: __module

- ##### hand: __module

- ##### nanodet: __module

### config

config: Config

Current configuration

- Details: Config

### draw

draw: { all: (inCanvas: HTMLCanvasElement, result: Result, drawOptions?: DrawOptions) => Promise<void>; body: (inCanvas: HTMLCanvasElement, result: Body[], drawOptions?: DrawOptions) => Promise<void>; canvas: (inCanvas: HTMLCanvasElement, outCanvas: HTMLCanvasElement) => Promise<void>; face: (inCanvas: HTMLCanvasElement, result: Face[], drawOptions?: DrawOptions) => Promise<void>; gesture: (inCanvas: HTMLCanvasElement, result: Gesture[], drawOptions?: DrawOptions) => Promise<void>; hand: (inCanvas: HTMLCanvasElement, result: Hand[], 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: Result, drawOptions?: DrawOptions) => Promise<void>

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

    - #### Parameters

      - ##### inCanvas: HTMLCanvasElement

      - ##### result: Result

      - ##### Optional drawOptions: DrawOptions

      #### Returns Promise<void>

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

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

    - #### Parameters

      - ##### inCanvas: HTMLCanvasElement

      - ##### result: Body[]

      - ##### 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: Face[], drawOptions?: DrawOptions) => Promise<void>

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

    - #### Parameters

      - ##### inCanvas: HTMLCanvasElement

      - ##### result: Face[]

      - ##### Optional drawOptions: DrawOptions

      #### Returns Promise<void>

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

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

    - #### Parameters

      - ##### inCanvas: HTMLCanvasElement

      - ##### result: Gesture[]

      - ##### Optional drawOptions: DrawOptions

      #### Returns Promise<void>

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

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

    - #### Parameters

      - ##### inCanvas: HTMLCanvasElement

      - ##### result: Hand[]

      - ##### 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 | Tensor<Rank> }

Internal: Instance of current image being processed

#### Type declaration

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

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

### models

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

Internal: Currently loaded models

#### Type declaration

- ##### age: unknown

- ##### blazepose: unknown

- ##### centernet: unknown

- ##### efficientpose: unknown

- ##### embedding: unknown

- ##### emotion: unknown

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

- ##### faceres: unknown

- ##### gender: unknown

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

- ##### iris: unknown

- ##### nanodet: unknown

- ##### posenet: unknown

### perf

perf: Record<string, unknown>

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?: Config | Record<string, unknown>): 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: Config | Record<string, unknown> = {}

  #### Returns Promise<Error | Result>

### enhance

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

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

  #### Parameters

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

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

  #### Returns null | Tensor<Rank>

  Tensor

### load

- load(userConfig?: Config | Record<string, unknown>): 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: Config | Record<string, unknown> = {}

  #### 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?: Config | Record<string, unknown>): 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: Config | Record<string, unknown> = {}

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