Skip to content

Processor

Core generic processor

Processor is a computational core of any application and the most essential part of the Engine in an app’s pipeline. Processing results are used by Renderer to update scene. Every processor must define methods to initialize and release instances required for image processing, and evaluation of processing results on provided image (where all logic happens). Processor is a generic abstract class defining common API.

ResultT extends object = { }

Type of processing results

ParamsT extends ProcParams = ProcParams

Type of processor parameters

new Processor<ResultT, ParamsT>(): Processor<ResultT, ParamsT>

Constructor

Processor<ResultT, ParamsT>

EventEmitterT.constructor

cameraAngle: number

Camera vertical angle in radians


cameraRatio: number

Camera aspect ratio


optimalSize: number = 1024

Recommended maximum size of input


protected params: Partial<ParamsT> = {}

Processor parameters


protected videoRatio: number

Aspect ratio of input video


protected videoSize: Size

Resolution of input video

addListener<E>(event, listener): this

Adds the listener function to the end of the listeners array

E extends keyof ProcessorEvents

E

The name of the event

ProcessorEvents[E]

The callback function

this

This EventEmitter

EventEmitterT.addListener


dispose(): void

Dispose processor object

Releases resources and instances allocated by processor. Processor object cannot be used after calling dispose(). Overridden by derived classes for particular processing.

void


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

Synchronously calls each of the listeners registered for the event

E extends keyof ProcessorEvents

E

The name of the event

Args<ProcessorEvents[E]>

Arguments passed to the listeners

boolean

True if the event had listeners, False otherwise

EventEmitterT.emit


eventNames(): (string | symbol)[]

List of emitter’s events

(string | symbol)[]

List of emitter’s events

EventEmitterT.eventNames


getMaxListeners(): number

Maximum number of listeners per event

number

Maximum number of listeners per event

EventEmitterT.getMaxListeners


init(params, size?, ratio?): Promise<boolean>

Initialize processor

Initializes all resources required for video processing. Overridden by derived classes for particular application.

ParamsT

Processor parameters

Size

Resolution of input video

number

Aspect ration of input video

Promise<boolean>

Status of initialization


listenerCount<E>(event): number

The number of listeners listening to the event

E extends keyof ProcessorEvents

E

The name of the event

number

Number of listeners

EventEmitterT.listenerCount


listeners<E>(event): Function[]

Copy of the array of listeners for the event

E extends keyof ProcessorEvents

E

The name of the event

Function[]

Copy of the listeners array

EventEmitterT.listeners


off<E>(event, listener): this

Removes the listener from the listener array for the event

E extends keyof ProcessorEvents

E

The name of the event

ProcessorEvents[E]

The callback function

this

This EventEmitter

EventEmitterT.off


on<E>(event, listener): this

Adds the listener function to the event

E extends keyof ProcessorEvents

E

The name of the event

ProcessorEvents[E]

The callback function

this

This EventEmitter

EventEmitterT.on


once<E>(event, listener): this

Adds a one-time listener function for the event

E extends keyof ProcessorEvents

E

The name of the event

ProcessorEvents[E]

The callback function

this

This EventEmitter

EventEmitterT.once


prependListener<E>(event, listener): this

Adds the listener function to the beginning of the listeners array

E extends keyof ProcessorEvents

E

The name of the event

ProcessorEvents[E]

The callback function

this

This EventEmitter

EventEmitterT.prependListener


prependOnceListener<E>(event, listener): this

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

E extends keyof ProcessorEvents

E

The name of the event

ProcessorEvents[E]

The callback function

this

EventEmitterT.prependOnceListener


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

Process the image

Main method defining the logic of video processing. Overridden by derived classes for particular application.

ImageInput

Image

number

Timestamp

Promise<ResultT>


rawListeners<E>(event): Function[]

Copy of the array of listeners for the event including wrappers

E extends keyof ProcessorEvents

E

The name of the event

Function[]

Copy of the listeners array

EventEmitterT.rawListeners


removeAllListeners<E>(event?): this

Removes all listeners, or those of the specified event

E extends keyof ProcessorEvents

E

The name of the event

this

This EventEmitter

EventEmitterT.removeAllListeners


removeListener<E>(event, listener): this

Removes the specified listener from the listener array

E extends keyof ProcessorEvents

E

The name of the event

ProcessorEvents[E]

The callback function

this

This EventEmitter

EventEmitterT.removeListener


reset(): void

Reset processor

Resets all processing instances to the initial state. Overridden by derived classes for particular processing.

void


setMaxListeners(n): this

Sets maximum number of listeners per event

number

Maximum number of listeners

this

This EventEmitter

EventEmitterT.setMaxListeners


setupVideo(size, ratio?): void

Set resolution of the input video

Could be overridden to adjust processing pipeline.

Size

Resolution of input video

number

Aspect ration of input video

void