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
new ImageBuffer()
new ImageBuffer(
name
):ImageBuffer
Constructor
Parameters
• name: string
= "canvas"
Optional name of canvas
Returns
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
• video: ImageBitmap
| HTMLCanvasElement
| HTMLVideoElement
Element 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
• clip?: ClipRect
Clipping rectangle in [0..1] space
Returns
void
setSize()
setSize(
size
):void
Set input video size
Parameters
• size: Size
Video size
Returns
void
setTranspose()
setTranspose(
transpose
):void
Set image transposition
Parameters
• transpose: boolean
Transpose image flag
Returns
void