Class: VideoCapture
@geenee/armature.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.
Hierarchy
↳
VideoCapture
Constructors
constructor
• new VideoCapture()
Constructor
Overrides
Properties
buffer
• buffer: ImageBuffer
Context of original stream
Inherited from
captureTime
• captureTime: number
= 0
Timestamp of the last captured frame
Inherited from
videoRef
• Protected
videoRef: HTMLVideoElement
Video element
Methods
addListener
▸ addListener<E
>(event
, listener
): VideoCapture
Adds the listener function to the end of the listeners array
Type parameters
Name | Type |
---|---|
E | extends "resize" |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | CaptureEvents [E ] | The callback function |
Returns
This EventEmitter
Inherited from
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
boolean
True if next frame was available and grabbed
Overrides
dispose
▸ dispose(): void
Dispose video capture object
Returns
void
Overrides
emit
▸ emit<E
>(event
, ...args
): boolean
Synchronously calls each of the listeners registered for the event
Type parameters
Name | Type |
---|---|
E | extends "resize" |
Parameters
Name | Type | Description |
---|---|---|
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
eventNames
▸ eventNames(): (string
| symbol
)[]
List of emitter's events
Returns
(string
| symbol
)[]
List of emitter's events
Inherited from
getMaxListeners
▸ getMaxListeners(): number
Maximum number of listeners per event
Returns
number
Maximum number of listeners per event
Inherited from
listenerCount
▸ listenerCount<E
>(event
): number
The number of listeners listening to the event
Type parameters
Name | Type |
---|---|
E | extends "resize" |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
Returns
number
Number of listeners
Inherited from
listeners
▸ listeners<E
>(event
): Function
[]
Copy of the array of listeners for the event
Type parameters
Name | Type |
---|---|
E | extends "resize" |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
Returns
Function
[]
Copy of the listeners array
Inherited from
off
▸ off<E
>(event
, listener
): VideoCapture
Removes the listener from the listener array for the event
Type parameters
Name | Type |
---|---|
E | extends "resize" |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | CaptureEvents [E ] | The callback function |
Returns
This EventEmitter
Inherited from
on
▸ on<E
>(event
, listener
): VideoCapture
Adds the listener function to the event
Type parameters
Name | Type |
---|---|
E | extends "resize" |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | CaptureEvents [E ] | The callback function |
Returns
This EventEmitter
Inherited from
once
▸ once<E
>(event
, listener
): VideoCapture
Adds a one-time listener function for the event
Type parameters
Name | Type |
---|---|
E | extends "resize" |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | CaptureEvents [E ] | The callback function |
Returns
This EventEmitter
Inherited from
pause
▸ pause(): void
Pause video capture
Returns
void
Overrides
prependListener
▸ prependListener<E
>(event
, listener
): VideoCapture
Adds the listener function to the beginning of the listeners array
Type parameters
Name | Type |
---|---|
E | extends "resize" |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | CaptureEvents [E ] | The callback function |
Returns
This EventEmitter
Inherited from
prependOnceListener
▸ prependOnceListener<E
>(event
, listener
): VideoCapture
Adds a one-time listener function to the beginning of the listeners array
Type parameters
Name | Type |
---|---|
E | extends "resize" |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | CaptureEvents [E ] | The callback function |
Returns
Inherited from
VideoSource.prependOnceListener
ratio
▸ ratio(): number
Aspect ratio of the video stream
Returns
number
Aspect ratio of the video stream
Inherited from
rawListeners
▸ rawListeners<E
>(event
): Function
[]
Copy of the array of listeners for the event including wrappers
Type parameters
Name | Type |
---|---|
E | extends "resize" |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
Returns
Function
[]
Copy of the listeners array
Inherited from
removeAllListeners
▸ removeAllListeners<E
>(event?
): VideoCapture
Removes all listeners, or those of the specified event
Type parameters
Name | Type |
---|---|
E | extends "resize" |
Parameters
Name | Type | Description |
---|---|---|
event? | E | The name of the event |
Returns
This EventEmitter
Inherited from
VideoSource.removeAllListeners
removeListener
▸ removeListener<E
>(event
, listener
): VideoCapture
Removes the specified listener from the listener array
Type parameters
Name | Type |
---|---|
E | extends "resize" |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | CaptureEvents [E ] | The callback function |
Returns
This EventEmitter
Inherited from
reset
▸ reset(): void
Reset video capture
After reset() capture may be started again only after setup().
Returns
void
Overrides
setMaxListeners
▸ setMaxListeners(n
): VideoCapture
Sets maximum number of listeners per event
Parameters
Name | Type | Description |
---|---|---|
n | number | Maximum number of listeners |
Returns
This EventEmitter
Inherited from
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, custom MediaStreamConstraints providing the most flexible way to select the video stream (for example set deviceId), external MediaStream allowing use of custom video sources, or string defining a media file as source of video stream.
Parameters
Name | Type | Description |
---|---|---|
params? | VideoSourceParams | Parameters of video capture |
Returns
Promise
<boolean
>
Promise resolved to the status of setup when finished
Overrides
size
▸ size(): Size
Resolution of the video stream
Returns
Resolution of the video stream
Inherited from
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
updateSize
▸ Protected
updateSize(size
): void
Update callback on video resize
Parameters
Name | Type | Description |
---|---|---|
size | Size | New size of the video stream |
Returns
void