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.

Extends

Constructors

new ImageCapture()

new ImageCapture(): ImageCapture

Constructor

Returns

ImageCapture

Inherited from

VideoSource.constructor

Properties

buffer

buffer: ImageBuffer

Context of original stream

Inherited from

VideoSource.buffer


captureTime

captureTime: number = 0

Timestamp of the last captured frame

Inherited from

VideoSource.captureTime


clipRect?

protected optional clipRect: ClipRect

Clipping rectangle

Inherited from

VideoSource.clipRect


imageRef?

protected optional imageRef: ImageBitmap

Image bitmap


sizeMax?

protected optional sizeMax: number

Maximum capture resolutions

Inherited from

VideoSource.sizeMax


transpose?

protected optional transpose: boolean

Transpose frames

Inherited from

VideoSource.transpose

Methods

addListener()

addListener<E>(event, listener): this

Adds the listener function to the end of the listeners array

Type Parameters

E extends "resize"

Parameters

event: E

The name of the event

listener: CaptureEvents[E]

The callback function

Returns

this

This EventEmitter

Inherited from

VideoSource.addListener


capture()

capture(): boolean

Grab the next video frame

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

Returns

boolean

True if next frame was available and grabbed

Overrides

VideoSource.capture


dispose()

dispose(): void

Dispose video capture object

Returns

void

Overrides

VideoSource.dispose


emit()

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

Synchronously calls each of the listeners registered for the event

Type Parameters

E extends "resize"

Parameters

event: E

The name of the event

• …args: Args<CaptureEvents[E]>

Arguments passed to the listeners

Returns

boolean

True if the event had listeners, False otherwise

Inherited from

VideoSource.emit


eventNames()

eventNames(): (string | symbol)[]

List of emitter’s events

Returns

(string | symbol)[]

List of emitter’s events

Inherited from

VideoSource.eventNames


getMaxListeners()

getMaxListeners(): number

Maximum number of listeners per event

Returns

number

Maximum number of listeners per event

Inherited from

VideoSource.getMaxListeners


listenerCount()

listenerCount<E>(event): number

The number of listeners listening to the event

Type Parameters

E extends "resize"

Parameters

event: E

The name of the event

Returns

number

Number of listeners

Inherited from

VideoSource.listenerCount


listeners()

listeners<E>(event): Function[]

Copy of the array of listeners for the event

Type Parameters

E extends "resize"

Parameters

event: E

The name of the event

Returns

Function[]

Copy of the listeners array

Inherited from

VideoSource.listeners


off()

off<E>(event, listener): this

Removes the listener from the listener array for the event

Type Parameters

E extends "resize"

Parameters

event: E

The name of the event

listener: CaptureEvents[E]

The callback function

Returns

this

This EventEmitter

Inherited from

VideoSource.off


on()

on<E>(event, listener): this

Adds the listener function to the event

Type Parameters

E extends "resize"

Parameters

event: E

The name of the event

listener: CaptureEvents[E]

The callback function

Returns

this

This EventEmitter

Inherited from

VideoSource.on


once()

once<E>(event, listener): this

Adds a one-time listener function for the event

Type Parameters

E extends "resize"

Parameters

event: E

The name of the event

listener: CaptureEvents[E]

The callback function

Returns

this

This EventEmitter

Inherited from

VideoSource.once


pause()

pause(): void

Pause video capture

Returns

void

Overrides

VideoSource.pause


prependListener()

prependListener<E>(event, listener): this

Adds the listener function to the beginning of the listeners array

Type Parameters

E extends "resize"

Parameters

event: E

The name of the event

listener: CaptureEvents[E]

The callback function

Returns

this

This EventEmitter

Inherited from

VideoSource.prependListener


prependOnceListener()

prependOnceListener<E>(event, listener): this

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

Type Parameters

E extends "resize"

Parameters

event: E

The name of the event

listener: CaptureEvents[E]

The callback function

Returns

this

Inherited from

VideoSource.prependOnceListener


ratio()

ratio(): number

Aspect ratio of the video stream

Returns

number

Aspect ratio of the video stream

Inherited from

VideoSource.ratio


rawListeners()

rawListeners<E>(event): Function[]

Copy of the array of listeners for the event including wrappers

Type Parameters

E extends "resize"

Parameters

event: E

The name of the event

Returns

Function[]

Copy of the listeners array

Inherited from

VideoSource.rawListeners


removeAllListeners()

removeAllListeners<E>(event?): this

Removes all listeners, or those of the specified event

Type Parameters

E extends "resize"

Parameters

event?: E

The name of the event

Returns

this

This EventEmitter

Inherited from

VideoSource.removeAllListeners


removeListener()

removeListener<E>(event, listener): this

Removes the specified listener from the listener array

Type Parameters

E extends "resize"

Parameters

event: E

The name of the event

listener: CaptureEvents[E]

The callback function

Returns

this

This EventEmitter

Inherited from

VideoSource.removeListener


reset()

reset(): void

Reset video capture

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

Returns

void

Overrides

VideoSource.reset


setMaxListeners()

setMaxListeners(n): this

Sets maximum number of listeners per event

Parameters

n: number

Maximum number of listeners

Returns

this

This EventEmitter

Inherited from

VideoSource.setMaxListeners


setup()

setup(params?): Promise<boolean>

Setup video capture

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

Parameters

params?: VideoSourceParams

Parameters of video capture

Returns

Promise<boolean>

Promise resolved to the status of setup when finished

Overrides

VideoSource.setup


size()

size(): Size

Resolution of the video stream

Returns

Size

Resolution of the video stream

Inherited from

VideoSource.size


start()

start(): Promise<void>

Start video capture

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

Returns

Promise<void>

Promise resolved when capture is started

Overrides

VideoSource.start


updateSize()

protected updateSize(size): void

Update callback on video resize

Parameters

size: Size

New size of the video stream

Returns

void

Inherited from

VideoSource.updateSize