VideoCapture
Video capture
VideoCapture object provides means to grab images from a source. It implements all required functionality including video device initialization, setup, start/stop of capture and frame grabbing. Internally VideoCapture utilizes ImageBuffer as storage.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new VideoCapture():
VideoCapture
Constructor
Returns
Section titled “Returns”VideoCapture
Overrides
Section titled “Overrides”Properties
Section titled “Properties”aspectRatio?
Section titled “aspectRatio?”
protected
optional
aspectRatio:number
Aspect ratio
Inherited from
Section titled “Inherited from”buffer
Section titled “buffer”buffer:
ImageBuffer
Context of original stream
Inherited from
Section titled “Inherited from”captureTime
Section titled “captureTime”captureTime:
number
=0
Timestamp of the last captured frame
Inherited from
Section titled “Inherited from”clipRect?
Section titled “clipRect?”
protected
optional
clipRect:ClipRect
Clipping rectangle
Inherited from
Section titled “Inherited from”sizeMax?
Section titled “sizeMax?”
protected
optional
sizeMax:number
Maximum capture resolutions
Inherited from
Section titled “Inherited from”transpose?
Section titled “transpose?”
protected
optional
transpose:boolean
Transpose frames
Inherited from
Section titled “Inherited from”videoRef
Section titled “videoRef”
protected
videoRef:HTMLVideoElement
Video element
Methods
Section titled “Methods”addListener()
Section titled “addListener()”addListener<
E
>(event
,listener
):this
Adds the listener function to the end of the listeners array
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”CaptureEvents
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”capture()
Section titled “capture()”capture():
boolean
Grab the next video frame
VideoCapture grabs the next image from a video source (camera) and stores it in embedded ImageBuffer.
Returns
Section titled “Returns”boolean
True if next frame was available and grabbed
Overrides
Section titled “Overrides”dispose()
Section titled “dispose()”dispose():
void
Dispose video capture object
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”emit()
Section titled “emit()”emit<
E
>(event
, …args
):boolean
Synchronously calls each of the listeners registered for the event
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
…Args
<CaptureEvents
[E
]>
Arguments passed to the listeners
Returns
Section titled “Returns”boolean
True if the event had listeners, False otherwise
Inherited from
Section titled “Inherited from”eventNames()
Section titled “eventNames()”eventNames(): (
string
|symbol
)[]
List of emitter’s events
Returns
Section titled “Returns”(string
| symbol
)[]
List of emitter’s events
Inherited from
Section titled “Inherited from”getMaxListeners()
Section titled “getMaxListeners()”getMaxListeners():
number
Maximum number of listeners per event
Returns
Section titled “Returns”number
Maximum number of listeners per event
Inherited from
Section titled “Inherited from”listenerCount()
Section titled “listenerCount()”listenerCount<
E
>(event
):number
The number of listeners listening to the event
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
Returns
Section titled “Returns”number
Number of listeners
Inherited from
Section titled “Inherited from”listeners()
Section titled “listeners()”listeners<
E
>(event
):Function
[]
Copy of the array of listeners for the event
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
Returns
Section titled “Returns”Function
[]
Copy of the listeners array
Inherited from
Section titled “Inherited from”off<
E
>(event
,listener
):this
Removes the listener from the listener array for the event
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”CaptureEvents
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”on<
E
>(event
,listener
):this
Adds the listener function to the event
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”CaptureEvents
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”once()
Section titled “once()”once<
E
>(event
,listener
):this
Adds a one-time listener function for the event
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”CaptureEvents
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”pause()
Section titled “pause()”pause():
void
Pause video capture
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”prependListener()
Section titled “prependListener()”prependListener<
E
>(event
,listener
):this
Adds the listener function to the beginning of the listeners array
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”CaptureEvents
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”prependOnceListener()
Section titled “prependOnceListener()”prependOnceListener<
E
>(event
,listener
):this
Adds a one-time listener function to the beginning of the listeners array
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”CaptureEvents
[E
]
The callback function
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”VideoSource
.prependOnceListener
ratio()
Section titled “ratio()”ratio():
number
Aspect ratio of the video stream
Returns
Section titled “Returns”number
Aspect ratio of the video stream
Inherited from
Section titled “Inherited from”rawListeners()
Section titled “rawListeners()”rawListeners<
E
>(event
):Function
[]
Copy of the array of listeners for the event including wrappers
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
Returns
Section titled “Returns”Function
[]
Copy of the listeners array
Inherited from
Section titled “Inherited from”removeAllListeners()
Section titled “removeAllListeners()”removeAllListeners<
E
>(event?
):this
Removes all listeners, or those of the specified event
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”event?
Section titled “event?”E
The name of the event
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”VideoSource
.removeAllListeners
removeListener()
Section titled “removeListener()”removeListener<
E
>(event
,listener
):this
Removes the specified listener from the listener array
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”CaptureEvents
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”reset()
Section titled “reset()”reset():
void
Reset video capture
After reset() capture may be started again only after setup().
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”setMaxListeners()
Section titled “setMaxListeners()”setMaxListeners(
n
):this
Sets maximum number of listeners per event
Parameters
Section titled “Parameters”number
Maximum number of listeners
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”setup()
Section titled “setup()”setup(
params?
):Promise
<boolean
>
Setup video capture
Sets up video device, streams and contexts with canvases.
Video capture can be setup by simplified VideoParams
opening default front/rear camera with provided resolution.
Additional fine-grained MediaStreamConstraints can be passed
via opts
field providing the most flexible way to setup
video stream (for example, by requesting specific deviceId).
Stream constraints have higher priority than rest or params.
Another options are an external MediaStream allowing custom
video sources (e.g. remote stream) or a media file defined
by url or FileParams that allows to limit maximum
capture size in cases resolution is too big for a device.
Parameters
Section titled “Parameters”params?
Section titled “params?”Parameters of video capture
Returns
Section titled “Returns”Promise
<boolean
>
Promise resolved to the status of setup when finished
Overrides
Section titled “Overrides”size()
Section titled “size()”size():
Size
Resolution of the video stream
Returns
Section titled “Returns”Resolution of the video stream
Inherited from
Section titled “Inherited from”start()
Section titled “start()”start():
Promise
<void
>
Start video capture
Video capture can be started only after successful setup().
Returns
Section titled “Returns”Promise
<void
>
Promise resolved when capture is started
Overrides
Section titled “Overrides”updateSize()
Section titled “updateSize()”
protected
updateSize(size
):void
Update callback on video resize
Parameters
Section titled “Parameters”New size of the video stream
Returns
Section titled “Returns”void