@capturebridge/sdk 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Camera.js +68 -68
- package/CanonCamera.js +25 -25
- package/CaptureBridge.js +162 -162
- package/CapturePlugin.js +79 -79
- package/Common.js +98 -98
- package/Device.js +451 -451
- package/ICAO.js +70 -70
- package/IFace.js +274 -274
- package/Logs.js +129 -129
- package/MockCamera.js +10 -10
- package/Plugin.js +298 -298
- package/Scanner.js +64 -64
- package/SignatureTablet.js +109 -109
- package/SignatureTabletWidgets.js +153 -153
- package/StreamingCapturePlugin.js +121 -121
- package/TopazSigGem.js +25 -25
- package/package.json +1 -1
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
import CapturePlugin from './CapturePlugin.js'
|
|
2
|
-
import { BASE_URL, DATAURL_JPEG, blobToBuffer } from './Common.js'
|
|
3
|
-
|
|
4
|
-
class StreamingCapturePlugin extends CapturePlugin {
|
|
5
|
-
constructor (plugin, baseUrl = BASE_URL) {
|
|
6
|
-
super(plugin, baseUrl)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Get the CapturePlugin's stream endpoint URL.
|
|
11
|
-
*
|
|
12
|
-
* @description The URL returned from this endpoint can be attached to an
|
|
13
|
-
* img tag's src attribute. The camera's live stream will be started and
|
|
14
|
-
* begin streaming to the img tag as a
|
|
15
|
-
* {@link https://en.wikipedia.org/wiki/Motion_JPEG|Motion JPEG} stream.
|
|
16
|
-
* If the src is changed, the img removed from the DOM, or client disconnected
|
|
17
|
-
* for any reason, the live feed will automatically be stopped.
|
|
18
|
-
*
|
|
19
|
-
* @param {string|object} [deviceOpt] - Get the stream URL from either a
|
|
20
|
-
* specific Device ID or a Device Object. The default is the first available
|
|
21
|
-
* device.
|
|
22
|
-
*
|
|
23
|
-
* @async
|
|
24
|
-
* @method
|
|
25
|
-
* @returns {string} stream endpoint URL
|
|
26
|
-
* @example
|
|
27
|
-
* const img = document.createElement('img')
|
|
28
|
-
* img.src = await camera.streamUrl()
|
|
29
|
-
* document.body.appendChild(img)
|
|
30
|
-
*/
|
|
31
|
-
async streamUrl (deviceOpt) {
|
|
32
|
-
const device = await this.setupDevice(deviceOpt)
|
|
33
|
-
return device.streamUrl()
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Get the most recent frame from a device's live feed.
|
|
38
|
-
*
|
|
39
|
-
* @description This method will startup the device's live
|
|
40
|
-
* feed if necessary and wait for it to initialize before returning a frame.
|
|
41
|
-
* Subsequent calls will return the next available frame.
|
|
42
|
-
* You must manually stop the live feed if you are using this method.
|
|
43
|
-
*
|
|
44
|
-
* If implementing a real-time preview, it is highly recommended to use the
|
|
45
|
-
* stream endpoint which will stream a Motion JPEG.
|
|
46
|
-
*
|
|
47
|
-
* @see {@link CapturePlugin#streamUrl}
|
|
48
|
-
* @see {@link CapturePlugin#stopFeed}
|
|
49
|
-
*
|
|
50
|
-
* @param {string} [kind=buffer] - Specify how to return the captured image. Valid
|
|
51
|
-
* values are 'blob', 'buffer', 'base64', or 'dataurl'.
|
|
52
|
-
*
|
|
53
|
-
* The default value of 'buffer' will load the image into an
|
|
54
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer|ArrayBuffer}
|
|
55
|
-
* that can be set directly on an img tag's src attribute.
|
|
56
|
-
*
|
|
57
|
-
* The value of 'blob' will return a
|
|
58
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Blob|Blob} that can
|
|
59
|
-
* be used with a
|
|
60
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/FileReader|FileReader}.
|
|
61
|
-
*
|
|
62
|
-
* The value of 'base64' will return the image contents as a
|
|
63
|
-
* {@link https://en.wikipedia.org/wiki/Base64|Base64} encoded string that is
|
|
64
|
-
* suitable for use with JSON serialization.
|
|
65
|
-
*
|
|
66
|
-
* The value of 'dataurl' will return a JPEG
|
|
67
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs|Data URL}
|
|
68
|
-
* that can be set on an img tag's src attribute or loaded as a document
|
|
69
|
-
* location.
|
|
70
|
-
*
|
|
71
|
-
* @param {string|object} [deviceOpt] - Return the frame from either a
|
|
72
|
-
* specific Device ID or a Device Object. The default, if not supplied, is the
|
|
73
|
-
* first available device.
|
|
74
|
-
*
|
|
75
|
-
* @async
|
|
76
|
-
* @method
|
|
77
|
-
* @example
|
|
78
|
-
* // Get the most recent frame from the camera's live feed as an ArrayBuffer
|
|
79
|
-
* // and add it to an img tag appended to the document's body.
|
|
80
|
-
* const img = document.createElement('img')
|
|
81
|
-
* img.src = await camera.getMostRecentFrame()
|
|
82
|
-
* document.body.appendChild(img)
|
|
83
|
-
*
|
|
84
|
-
* // Stop the live feed when done getting frames
|
|
85
|
-
* await camera.stopFeed()
|
|
86
|
-
*/
|
|
87
|
-
async getMostRecentFrame (kind = 'buffer', deviceOpt) {
|
|
88
|
-
const device = await this.setupDevice(deviceOpt)
|
|
89
|
-
switch (kind) {
|
|
90
|
-
case 'blob':
|
|
91
|
-
return await device.frameAsBlob()
|
|
92
|
-
case 'buffer':
|
|
93
|
-
return await blobToBuffer(await device.frameAsBlob())
|
|
94
|
-
case 'base64':
|
|
95
|
-
return await device.frameAsBase64()
|
|
96
|
-
case 'dataurl':
|
|
97
|
-
return DATAURL_JPEG + (await device.frameAsBase64())
|
|
98
|
-
}
|
|
99
|
-
throw new Error(`Unknown image response type: ${kind}`)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Stop the camera's live feed if it is running.
|
|
104
|
-
*
|
|
105
|
-
* @method
|
|
106
|
-
* @async
|
|
107
|
-
* @returns {object} Status of the stop operation
|
|
108
|
-
* @example
|
|
109
|
-
* // CapturePlugin is now running it's live feed in a background thread
|
|
110
|
-
* const frame = await camera.getMostRecentFrame()
|
|
111
|
-
* // Do some stuff with frame...
|
|
112
|
-
* // Stop the live feed
|
|
113
|
-
* console.log(await camera.stopFeed())
|
|
114
|
-
*/
|
|
115
|
-
async stopFeed (deviceOpt) {
|
|
116
|
-
const device = await this.setupDevice(deviceOpt)
|
|
117
|
-
return await device.stopFeed()
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export default StreamingCapturePlugin
|
|
1
|
+
import CapturePlugin from './CapturePlugin.js'
|
|
2
|
+
import { BASE_URL, DATAURL_JPEG, blobToBuffer } from './Common.js'
|
|
3
|
+
|
|
4
|
+
class StreamingCapturePlugin extends CapturePlugin {
|
|
5
|
+
constructor (plugin, baseUrl = BASE_URL) {
|
|
6
|
+
super(plugin, baseUrl)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get the CapturePlugin's stream endpoint URL.
|
|
11
|
+
*
|
|
12
|
+
* @description The URL returned from this endpoint can be attached to an
|
|
13
|
+
* img tag's src attribute. The camera's live stream will be started and
|
|
14
|
+
* begin streaming to the img tag as a
|
|
15
|
+
* {@link https://en.wikipedia.org/wiki/Motion_JPEG|Motion JPEG} stream.
|
|
16
|
+
* If the src is changed, the img removed from the DOM, or client disconnected
|
|
17
|
+
* for any reason, the live feed will automatically be stopped.
|
|
18
|
+
*
|
|
19
|
+
* @param {string|object} [deviceOpt] - Get the stream URL from either a
|
|
20
|
+
* specific Device ID or a Device Object. The default is the first available
|
|
21
|
+
* device.
|
|
22
|
+
*
|
|
23
|
+
* @async
|
|
24
|
+
* @method
|
|
25
|
+
* @returns {string} stream endpoint URL
|
|
26
|
+
* @example
|
|
27
|
+
* const img = document.createElement('img')
|
|
28
|
+
* img.src = await camera.streamUrl()
|
|
29
|
+
* document.body.appendChild(img)
|
|
30
|
+
*/
|
|
31
|
+
async streamUrl (deviceOpt) {
|
|
32
|
+
const device = await this.setupDevice(deviceOpt)
|
|
33
|
+
return device.streamUrl()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get the most recent frame from a device's live feed.
|
|
38
|
+
*
|
|
39
|
+
* @description This method will startup the device's live
|
|
40
|
+
* feed if necessary and wait for it to initialize before returning a frame.
|
|
41
|
+
* Subsequent calls will return the next available frame.
|
|
42
|
+
* You must manually stop the live feed if you are using this method.
|
|
43
|
+
*
|
|
44
|
+
* If implementing a real-time preview, it is highly recommended to use the
|
|
45
|
+
* stream endpoint which will stream a Motion JPEG.
|
|
46
|
+
*
|
|
47
|
+
* @see {@link CapturePlugin#streamUrl}
|
|
48
|
+
* @see {@link CapturePlugin#stopFeed}
|
|
49
|
+
*
|
|
50
|
+
* @param {string} [kind=buffer] - Specify how to return the captured image. Valid
|
|
51
|
+
* values are 'blob', 'buffer', 'base64', or 'dataurl'.
|
|
52
|
+
*
|
|
53
|
+
* The default value of 'buffer' will load the image into an
|
|
54
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer|ArrayBuffer}
|
|
55
|
+
* that can be set directly on an img tag's src attribute.
|
|
56
|
+
*
|
|
57
|
+
* The value of 'blob' will return a
|
|
58
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Blob|Blob} that can
|
|
59
|
+
* be used with a
|
|
60
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/FileReader|FileReader}.
|
|
61
|
+
*
|
|
62
|
+
* The value of 'base64' will return the image contents as a
|
|
63
|
+
* {@link https://en.wikipedia.org/wiki/Base64|Base64} encoded string that is
|
|
64
|
+
* suitable for use with JSON serialization.
|
|
65
|
+
*
|
|
66
|
+
* The value of 'dataurl' will return a JPEG
|
|
67
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs|Data URL}
|
|
68
|
+
* that can be set on an img tag's src attribute or loaded as a document
|
|
69
|
+
* location.
|
|
70
|
+
*
|
|
71
|
+
* @param {string|object} [deviceOpt] - Return the frame from either a
|
|
72
|
+
* specific Device ID or a Device Object. The default, if not supplied, is the
|
|
73
|
+
* first available device.
|
|
74
|
+
*
|
|
75
|
+
* @async
|
|
76
|
+
* @method
|
|
77
|
+
* @example
|
|
78
|
+
* // Get the most recent frame from the camera's live feed as an ArrayBuffer
|
|
79
|
+
* // and add it to an img tag appended to the document's body.
|
|
80
|
+
* const img = document.createElement('img')
|
|
81
|
+
* img.src = await camera.getMostRecentFrame()
|
|
82
|
+
* document.body.appendChild(img)
|
|
83
|
+
*
|
|
84
|
+
* // Stop the live feed when done getting frames
|
|
85
|
+
* await camera.stopFeed()
|
|
86
|
+
*/
|
|
87
|
+
async getMostRecentFrame (kind = 'buffer', deviceOpt) {
|
|
88
|
+
const device = await this.setupDevice(deviceOpt)
|
|
89
|
+
switch (kind) {
|
|
90
|
+
case 'blob':
|
|
91
|
+
return await device.frameAsBlob()
|
|
92
|
+
case 'buffer':
|
|
93
|
+
return await blobToBuffer(await device.frameAsBlob())
|
|
94
|
+
case 'base64':
|
|
95
|
+
return await device.frameAsBase64()
|
|
96
|
+
case 'dataurl':
|
|
97
|
+
return DATAURL_JPEG + (await device.frameAsBase64())
|
|
98
|
+
}
|
|
99
|
+
throw new Error(`Unknown image response type: ${kind}`)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Stop the camera's live feed if it is running.
|
|
104
|
+
*
|
|
105
|
+
* @method
|
|
106
|
+
* @async
|
|
107
|
+
* @returns {object} Status of the stop operation
|
|
108
|
+
* @example
|
|
109
|
+
* // CapturePlugin is now running it's live feed in a background thread
|
|
110
|
+
* const frame = await camera.getMostRecentFrame()
|
|
111
|
+
* // Do some stuff with frame...
|
|
112
|
+
* // Stop the live feed
|
|
113
|
+
* console.log(await camera.stopFeed())
|
|
114
|
+
*/
|
|
115
|
+
async stopFeed (deviceOpt) {
|
|
116
|
+
const device = await this.setupDevice(deviceOpt)
|
|
117
|
+
return await device.stopFeed()
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export default StreamingCapturePlugin
|
package/TopazSigGem.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import SignatureTablet from './SignatureTablet.js'
|
|
2
|
-
import { BASE_URL } from './Common.js'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* TopazSigGem
|
|
6
|
-
* @classdesc Convience class for instantiating a Topaz SigGem Signature Tablet
|
|
7
|
-
* Inherits all methods on the {@link SignatureTablet} class.
|
|
8
|
-
*
|
|
9
|
-
* @see {@link SignatureTablet}
|
|
10
|
-
*/
|
|
11
|
-
class TopazSigGem extends SignatureTablet {
|
|
12
|
-
/**
|
|
13
|
-
* Instantiate a Topaz SigGem Signature Tablet
|
|
14
|
-
* @constructor
|
|
15
|
-
* @param {string} [baseURL] - Protocol, domain, and port for the service.
|
|
16
|
-
* @example
|
|
17
|
-
* const camera = new TopazSigGem()
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
constructor (baseUrl = BASE_URL) {
|
|
21
|
-
super('capture_signature_topaz', baseUrl)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default TopazSigGem
|
|
1
|
+
import SignatureTablet from './SignatureTablet.js'
|
|
2
|
+
import { BASE_URL } from './Common.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* TopazSigGem
|
|
6
|
+
* @classdesc Convience class for instantiating a Topaz SigGem Signature Tablet
|
|
7
|
+
* Inherits all methods on the {@link SignatureTablet} class.
|
|
8
|
+
*
|
|
9
|
+
* @see {@link SignatureTablet}
|
|
10
|
+
*/
|
|
11
|
+
class TopazSigGem extends SignatureTablet {
|
|
12
|
+
/**
|
|
13
|
+
* Instantiate a Topaz SigGem Signature Tablet
|
|
14
|
+
* @constructor
|
|
15
|
+
* @param {string} [baseURL] - Protocol, domain, and port for the service.
|
|
16
|
+
* @example
|
|
17
|
+
* const camera = new TopazSigGem()
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
constructor (baseUrl = BASE_URL) {
|
|
21
|
+
super('capture_signature_topaz', baseUrl)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default TopazSigGem
|
package/package.json
CHANGED