Skip to main content

Class: PoseEngine

@geenee/bodyprocessors.PoseEngine

Pose engine

Specialization of @geenee/armature!Engine for PoseProcessor. Straightforward wrapper, instead of new Engine(PoseProcessor, ...) you can use simpler const engine = new PoseEngine(...}).

Hierarchy

Constructors

constructor

new PoseEngine(engineParams?, Source?)

Constructor

Parameters

NameTypeDefault valueDescription
engineParams?EngineParamsundefinedParameters of the engine
Source() => VideoSourceVideoCaptureVideo source class or instance

Overrides

Engine.constructor

Properties

engineParams

Protected Optional engineParams: EngineParams

Parameters of the engine

Inherited from

Engine.engineParams


init

init: (procParams: PoseParams) => Promise<boolean>

Type declaration

▸ (procParams): Promise<boolean>

Initialize engine. Sets up processor.

The SDK access token is required parameter that authenticates the user and enables the SDK on the current url. By default, path to required wasm modules provided with SDK packages is the current url. You can change the root path to wasms passing root parameter.

Parameters
NameTypeDescription
procParamsPoseParamsParameters of the processor
Returns

Promise<boolean>

Status of initialization

Inherited from

Engine.init


iterate

Protected iterate: () => Promise<void>

Type declaration

▸ (): Promise<void>

Iterate

Returns

Promise<void>

Inherited from

Engine.iterate


pause

pause: () => void

Type declaration

▸ (): void

Pause pipeline.

Nothing happens if pipeline is not started yet.

Returns

void

Inherited from

Engine.pause


processCanvas

Protected Optional processCanvas: HTMLCanvasElement

Shallow copy of canvas with video for processors

Inherited from

Engine.processCanvas


processSize

Protected processSize: Size

Size of video for processors

Inherited from

Engine.processSize


processor

Protected processor: PoseProcessor

Processor utilized by the engine

Inherited from

Engine.processor


renderers

Protected renderers: Renderer<PoseResult>[]

Renderer attached to the engine

Inherited from

Engine.renderers


reset

reset: () => void

Type declaration

▸ (): void

Reset pipeline

Stops pipeline, resets video capture and processor. After reset one needs to reinitialize video capture calling setup() before pipeline can be started again.

Returns

void

Inherited from

Engine.reset


resizeBuffer

Protected Optional resizeBuffer: ImageBuffer

Buffer to resize frames

Inherited from

Engine.resizeBuffer


resizeEnabled

Protected resizeEnabled: boolean

Original stream is resized

Inherited from

Engine.resizeEnabled


setup

setup: (videoParams?: VideoSourceParams) => Promise<boolean>

Type declaration

▸ (videoParams?): Promise<boolean>

Setup engine. Initializes video capture.

Video capture can be setup by simplified VideoParams opening default front/rear camera with provided resolution, custom MediaStreamConstraints providing the most flexible way to setup video stream (e.g. set deviceId), or external MediaStream allowing custom video sources (e.g. from file).

Parameters
NameTypeDescription
videoParams?VideoSourceParamsParameters of video capture
Returns

Promise<boolean>

Status of initialization

Inherited from

Engine.setup


start

start: () => Promise<void>

Type declaration

▸ (): Promise<void>

Start pipeline.

Pipeline can be started only after successful init and setup.

Returns

Promise<void>

Inherited from

Engine.start


streamCanvas

Protected Optional streamCanvas: HTMLCanvasElement

Shallow copy of canvas with video for renderers

Inherited from

Engine.streamCanvas


streamSize

Protected streamSize: Size

Size of video for renderers

Inherited from

Engine.streamSize


video

Protected video: VideoSource

Video source instance

Inherited from

Engine.video


videoRatio

Protected videoRatio: number

Ratio of video stream

Inherited from

Engine.videoRatio

Methods

addListener

addListener<E>(event, listener): PoseEngine

Adds the listener function to the end of the listeners array

Type parameters

NameType
Eextends keyof EngineEvents

Parameters

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

Returns

PoseEngine

This EventEmitter

Inherited from

Engine.addListener


addRenderer

addRenderer(renderer): Promise<void>

Attach Renderer to the engine

Parameters

NameTypeDescription
rendererRenderer<PoseResult>Object to be attached

Returns

Promise<void>

Inherited from

Engine.addRenderer


emit

emit<E>(event, ...args): boolean

Synchronously calls each of the listeners registered for the event

Type parameters

NameType
Eextends keyof EngineEvents

Parameters

NameTypeDescription
eventEThe name of the event
...argsArgs<EngineEvents[E]>Arguments passed to the listeners

Returns

boolean

True if the event had listeners, False otherwise

Inherited from

Engine.emit


enqueue

Protected enqueue(): void

Enqueue the next iteration

Returns

void

Inherited from

Engine.enqueue


eventNames

eventNames(): (string | symbol)[]

List of emitter's events

Returns

(string | symbol)[]

List of emitter's events

Inherited from

Engine.eventNames


getMaxListeners

getMaxListeners(): number

Maximum number of listeners per event

Returns

number

Maximum number of listeners per event

Inherited from

Engine.getMaxListeners


listenerCount

listenerCount<E>(event): number

The number of listeners listening to the event

Type parameters

NameType
Eextends keyof EngineEvents

Parameters

NameTypeDescription
eventEThe name of the event

Returns

number

Number of listeners

Inherited from

Engine.listenerCount


listeners

listeners<E>(event): Function[]

Copy of the array of listeners for the event

Type parameters

NameType
Eextends keyof EngineEvents

Parameters

NameTypeDescription
eventEThe name of the event

Returns

Function[]

Copy of the listeners array

Inherited from

Engine.listeners


off

off<E>(event, listener): PoseEngine

Removes the listener from the listener array for the event

Type parameters

NameType
Eextends keyof EngineEvents

Parameters

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

Returns

PoseEngine

This EventEmitter

Inherited from

Engine.off


on

on<E>(event, listener): PoseEngine

Adds the listener function to the event

Type parameters

NameType
Eextends keyof EngineEvents

Parameters

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

Returns

PoseEngine

This EventEmitter

Inherited from

Engine.on


once

once<E>(event, listener): PoseEngine

Adds a one-time listener function for the event

Type parameters

NameType
Eextends keyof EngineEvents

Parameters

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

Returns

PoseEngine

This EventEmitter

Inherited from

Engine.once


prependListener

prependListener<E>(event, listener): PoseEngine

Adds the listener function to the beginning of the listeners array

Type parameters

NameType
Eextends keyof EngineEvents

Parameters

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

Returns

PoseEngine

This EventEmitter

Inherited from

Engine.prependListener


prependOnceListener

prependOnceListener<E>(event, listener): PoseEngine

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

Type parameters

NameType
Eextends keyof EngineEvents

Parameters

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

Returns

PoseEngine

Inherited from

Engine.prependOnceListener


rawListeners

rawListeners<E>(event): Function[]

Copy of the array of listeners for the event including wrappers

Type parameters

NameType
Eextends keyof EngineEvents

Parameters

NameTypeDescription
eventEThe name of the event

Returns

Function[]

Copy of the listeners array

Inherited from

Engine.rawListeners


removeAllListeners

removeAllListeners<E>(event?): PoseEngine

Removes all listeners, or those of the specified event

Type parameters

NameType
Eextends keyof EngineEvents

Parameters

NameTypeDescription
event?EThe name of the event

Returns

PoseEngine

This EventEmitter

Inherited from

Engine.removeAllListeners


removeListener

removeListener<E>(event, listener): PoseEngine

Removes the specified listener from the listener array

Type parameters

NameType
Eextends keyof EngineEvents

Parameters

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

Returns

PoseEngine

This EventEmitter

Inherited from

Engine.removeListener


removeRenderer

removeRenderer(renderer): void

Remove attached Renderer

Parameters

NameTypeDescription
rendererRenderer<PoseResult>Renderer to be removed

Returns

void

Inherited from

Engine.removeRenderer


resizeVideo

Protected resizeVideo(size): void

Callback called when video resolution is changed

Parameters

NameTypeDescription
sizeSizeSize of the video

Returns

void

Inherited from

Engine.resizeVideo


setMaxListeners

setMaxListeners(n): PoseEngine

Sets maximum number of listeners per event

Parameters

NameTypeDescription
nnumberMaximum number of listeners

Returns

PoseEngine

This EventEmitter

Inherited from

Engine.setMaxListeners


setupProcessor

Protected setupProcessor(procParams): Promise<boolean>

Setup processor

Parameters

NameType
procParamsPoseParams

Returns

Promise<boolean>

Inherited from

Engine.setupProcessor


setupSize

Protected setupSize(size): Promise<void>

Setup video size

Parameters

NameType
sizeSize

Returns

Promise<void>

Inherited from

Engine.setupSize


setupVideo

Protected setupVideo(videoParams?): Promise<boolean>

Setup video capture

Parameters

NameType
videoParams?VideoSourceParams

Returns

Promise<boolean>

Inherited from

Engine.setupVideo