Skip to main content

Class: ImageBuffer

@geenee/armature.ImageBuffer

Image buffer

Helper class grabbing images into internal storage. Used by VideoSource to grab video streams and Engine to resize images for faster processing. Image can be accessed by canvas or read as pixels.

Constructors

constructor

new ImageBuffer(name?)

Constructor

Parameters

NameTypeDefault valueDescription
namestring"canvas"Optional name of canvas

Properties

canvas

canvas: HTMLCanvasElement

Canvas to capture frames


context

Protected context: null | CanvasRenderingContext2D = null

Context to capture frames


size

size: Size

Size of video

Methods

capture

capture(video): boolean

Grab frame

Grabs frame from video element or canvas into internal canvas. Automatically rescales an image if resolutions are different.

Parameters

NameTypeDescription
videoHTMLCanvasElement | HTMLVideoElementElement to grab image from

Returns

boolean

True if image is grabbed, False otherwise


data

data(): undefined | ImageData

Get image buffer

Returns data buffer of image currently grabbed into canvas.

Returns

undefined | ImageData

Image data buffer on success, undefined otherwise


dispose

dispose(): void

Dispose video context object

Returns

void


fill

fill(): void

Fill canvas with color

Returns

void


setSize

setSize(size): void

Set video size

Parameters

NameType
sizeSize

Returns

void