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


clip

Protected Optional clip: ClipRect

Clipping region in normalized coordinates


clipPix

Protected Optional clipPix: ClipRect

Clipping region in pixels


context

Protected context: null | CanvasRenderingContext2D = null

Context to capture frames


size

size: Size

Size of the frames


transpose

Protected transpose: boolean = false

Transpose image

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


setClip

setClip(clip?): void

Set normalized clipping rectangle

Parameters

NameTypeDescription
clip?ClipRectClipping rectangle in [0..1] space

Returns

void


setSize

setSize(size): void

Set input video size

Parameters

NameTypeDescription
sizeSizeVideo size

Returns

void


setTranspose

setTranspose(transpose): void

Set image transposition

Parameters

NameTypeDescription
transposebooleanTranspose image flag

Returns

void