Skip to content

ImageCapture

Image capture

ImageCapture grabs frames from a static source (image). It implements source initialization, setup, start/stop of capture, and frame grabbing. Internally, ImageCapture utilizes ImageBuffer as storage and fast resizer.

new ImageCapture(): ImageCapture

Constructor

ImageCapture

VideoSource.constructor

protected optional aspectRatio: number

Aspect ratio

VideoSource.aspectRatio


buffer: ImageBuffer

Context of original stream

VideoSource.buffer


captureTime: number = 0

Timestamp of the last captured frame

VideoSource.captureTime


protected optional clipRect: ClipRect

Clipping rectangle

VideoSource.clipRect


protected optional imageRef: ImageBitmap

Image bitmap


protected optional sizeMax: number

Maximum capture resolutions

VideoSource.sizeMax


protected optional transpose: boolean

Transpose frames

VideoSource.transpose

addListener<E>(event, listener): this

Adds the listener function to the end of the listeners array

E extends "resize"

E

The name of the event

CaptureEvents[E]

The callback function

this

This EventEmitter

VideoSource.addListener


capture(): boolean

Grab the next video frame

VideoCapture grabs the next frame from an image and stores it in embedded ImageBuffer.

boolean

True if next frame was available and grabbed

VideoSource.capture


dispose(): void

Dispose video capture object

void

VideoSource.dispose


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

Synchronously calls each of the listeners registered for the event

E extends "resize"

E

The name of the event

Args<CaptureEvents[E]>

Arguments passed to the listeners

boolean

True if the event had listeners, False otherwise

VideoSource.emit


eventNames(): (string | symbol)[]

List of emitter’s events

(string | symbol)[]

List of emitter’s events

VideoSource.eventNames


getMaxListeners(): number

Maximum number of listeners per event

number

Maximum number of listeners per event

VideoSource.getMaxListeners


listenerCount<E>(event): number

The number of listeners listening to the event

E extends "resize"

E

The name of the event

number

Number of listeners

VideoSource.listenerCount


listeners<E>(event): Function[]

Copy of the array of listeners for the event

E extends "resize"

E

The name of the event

Function[]

Copy of the listeners array

VideoSource.listeners


off<E>(event, listener): this

Removes the listener from the listener array for the event

E extends "resize"

E

The name of the event

CaptureEvents[E]

The callback function

this

This EventEmitter

VideoSource.off


on<E>(event, listener): this

Adds the listener function to the event

E extends "resize"

E

The name of the event

CaptureEvents[E]

The callback function

this

This EventEmitter

VideoSource.on


once<E>(event, listener): this

Adds a one-time listener function for the event

E extends "resize"

E

The name of the event

CaptureEvents[E]

The callback function

this

This EventEmitter

VideoSource.once


pause(): void

Pause video capture

void

VideoSource.pause


prependListener<E>(event, listener): this

Adds the listener function to the beginning of the listeners array

E extends "resize"

E

The name of the event

CaptureEvents[E]

The callback function

this

This EventEmitter

VideoSource.prependListener


prependOnceListener<E>(event, listener): this

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

E extends "resize"

E

The name of the event

CaptureEvents[E]

The callback function

this

VideoSource.prependOnceListener


ratio(): number

Aspect ratio of the video stream

number

Aspect ratio of the video stream

VideoSource.ratio


rawListeners<E>(event): Function[]

Copy of the array of listeners for the event including wrappers

E extends "resize"

E

The name of the event

Function[]

Copy of the listeners array

VideoSource.rawListeners


removeAllListeners<E>(event?): this

Removes all listeners, or those of the specified event

E extends "resize"

E

The name of the event

this

This EventEmitter

VideoSource.removeAllListeners


removeListener<E>(event, listener): this

Removes the specified listener from the listener array

E extends "resize"

E

The name of the event

CaptureEvents[E]

The callback function

this

This EventEmitter

VideoSource.removeListener


reset(): void

Reset video capture

After reset() capture may be started again only after setup().

void

VideoSource.reset


setMaxListeners(n): this

Sets maximum number of listeners per event

number

Maximum number of listeners

this

This EventEmitter

VideoSource.setMaxListeners


setup(params?): Promise<boolean>

Setup video capture

Loads image specified by a url and sets up a video capture.

VideoSourceParams

Parameters of video capture

Promise<boolean>

Promise resolved to the status of setup when finished

VideoSource.setup


size(): Size

Resolution of the video stream

Size

Resolution of the video stream

VideoSource.size


start(): Promise<void>

Start video capture

Video capture can be started only after successful setup().

Promise<void>

Promise resolved when capture is started

VideoSource.start


protected updateSize(size): void

Update callback on video resize

Size

New size of the video stream

void

VideoSource.updateSize