Extends
Members
baseUrl
- Source:
- Overrides:
Properties:
Name | Type | Description |
---|---|---|
id |
string | ID of the plugin, used when building REST endpoint paths. |
name |
string | Human friendly name for the plugin. |
description |
string | Human friendly description of plugin. |
version |
string | Semantic version version of the plugin. |
methods |
Array.<string> | A plugin's list of supported RPC methods. |
ready |
boolean | True if plugin has been loaded into memory and is ready to receive requests. |
defaultDevice |
object | Default device to use for the plugin. |
configMethods |
Array.<string> | Methods required to implement configuration. |
Methods
(async) device(id) → (nullable) {object}
- Description:
Get a device by ID for this plugin
- Source:
- Overrides:
- See:
Example
const plugin = await captureBridge.plugin('capture_camera_canon')
const device = await plugin.device('AWOOO56709')
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Device ID |
Returns:
Requested Device
or null
- Type
- object
(async) devices() → {Array.<object>}
- Description:
Get all devices for this plugin
- Source:
- Overrides:
- See:
Example
const plugin = await captureBridge.plugin('capture_camera_canon')
const devices = await plugin.devices()
Returns:
Array of Device
objects.
- Type
- Array.<object>
(async) fullCapture(captureOptopt, deviceOptopt)
- Description:
Take a full capture
- Source:
- Overrides:
Example
// Capture an image as an ArrayBuffer and add it to an img tag appended to
// the document's body.
const img = document.createElement('img')
img.src = await capture.fullCapture()
document.body.appendChild(img)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
captureOpt |
CaptureOptions |
<optional> |
Additional options for capturing an image. |
deviceOpt |
string | object |
<optional> |
Take the capture using either a specific Device ID or a Device Object. The default is the first available device. |
(async) getMostRecentFrame(captureOptopt, deviceOptopt)
- Description:
This method will startup the device's live feed if necessary and wait for it to initialize before returning a frame. Subsequent calls will return the next available frame. You must manually stop the live feed if you are using this method.
If implementing a real-time preview, it is highly recommended to use the stream endpoint which will stream a Motion JPEG.
- Source:
- Overrides:
- See:
-
CapturePlugin#streamUrl
CapturePlugin#stopFeed
Example
// Get the most recent frame from the camera's live feed as an ArrayBuffer
// and add it to an img tag appended to the document's body.
const img = document.createElement('img')
img.src = await camera.getMostRecentFrame()
document.body.appendChild(img)
// Stop the live feed when done getting frames
await camera.stopFeed()
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
captureOpt |
CaptureOptions |
<optional> |
Additional options for capturing a photo. |
deviceOpt |
string | object |
<optional> |
Return the frame from either a specific Device ID or a Device Object. The default, if not supplied, is the first available device. |
(async) hasMethod(method) → {boolean}
- Description:
Check if a plugin has an RPC method
- Source:
- Overrides:
Example
const canCapture = await plugin.hasMethod('capture')
Parameters:
Name | Type | Description |
---|---|---|
method |
string | An RPC method |
Returns:
Return true if plugin has the provided method.
- Type
- boolean
(async) shutdown(timeoutopt)
- Description:
Shutdown a plugin
- Source:
- Overrides:
- See:
Example
await plugin.shutdown()
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
timeout |
number |
<optional> |
10
|
Timeout in seconds. Forcefully terminate
the plugin if it doesn't shutdown cleanly within the specified timeout. A
value of |
(async) stopFeed(deviceOptopt) → {object}
- Description:
Stop the camera's live feed if it is running.
- Source:
- Overrides:
Example
// CapturePlugin is now running it's live feed in a background thread
const frame = await camera.getMostRecentFrame()
// Do some stuff with frame...
// Stop the live feed
console.log(await camera.stopFeed())
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
deviceOpt |
string | object |
<optional> |
Stop the feed for a specific Device ID or a Device Object. The default, if not supplied, is the first available device. |
Returns:
Status of the stop operation
- Type
- object
(async) streamUrl(streamOptopt, deviceOptopt) → {string}
- Description:
The URL returned from this endpoint can be attached to an img tag's src attribute. The camera's live stream will be started and begin streaming to the img tag as a Motion JPEG stream. If the src is changed, the img removed from the DOM, or client disconnected for any reason, the live feed will automatically be stopped.
- Source:
- Overrides:
Example
const img = document.createElement('img')
img.src = await camera.streamUrl()
document.body.appendChild(img)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
streamOpt |
StreamOptions |
<optional> |
Additional options for the stream. |
deviceOpt |
string | object |
<optional> |
Get the stream URL from either a specific Device ID or a Device Object. The default is the first available device. |
Returns:
stream endpoint URL
- Type
- string
(async) takePhoto(captureOptopt, deviceOptopt)
- Description:
Capture a photo
- Source:
- Overrides:
Example
// Capture a photo as an ObjectURL, add it to an img element and append to
// the document's body.
const img = document.createElement('img')
img.src = await camera.takePhoto()
document.body.appendChild(img)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
captureOpt |
CaptureOptions |
<optional> |
Additional options for capturing a photo. |
deviceOpt |
string | object |
<optional> |
Take the photo using either a specific Device ID or a Device Object. The default is the first available device. |