@capturebridge/sdk 0.7.0 → 0.8.0
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 +63 -68
- package/CanonCamera.js +25 -25
- package/CaptureBridge.js +160 -162
- package/CapturePlugin.js +68 -79
- package/Common.js +182 -98
- package/Device.js +547 -451
- package/ICAO.js +70 -70
- package/IFace.js +278 -274
- package/Logs.js +129 -129
- package/MockCamera.js +17 -10
- package/Plugin.js +299 -298
- package/Scanner.js +55 -64
- package/SignatureTablet.js +108 -109
- package/SignatureTabletWidgets.js +164 -153
- package/StreamingCapturePlugin.js +129 -121
- package/TopazSigGem.js +25 -25
- package/Version.js +8 -0
- package/WindowsScanner.js +25 -0
- package/examples/canon.html +66 -0
- package/examples/canon_getframe.html +68 -0
- package/examples/canon_lan.html +68 -0
- package/examples/canon_minimal.html +37 -0
- package/examples/mockcamera.html +61 -0
- package/examples/mockcamera_getframe.html +63 -0
- package/examples/mockcamera_minimal.html +31 -0
- package/examples/windows_scanner_minimal.html +32 -0
- package/package.json +2 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Scanner from './Scanner.js'
|
|
2
|
+
import { BASE_URL } from './Common.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* WindowsScanner
|
|
6
|
+
* @classdesc Convenience class for instantiating a WIA compatible Scanner.
|
|
7
|
+
* Inherits all methods on the {@link Scanner} class.
|
|
8
|
+
* @extends Scanner
|
|
9
|
+
* @see {@link Scanner}
|
|
10
|
+
*/
|
|
11
|
+
class WindowsScanner extends Scanner {
|
|
12
|
+
/**
|
|
13
|
+
* Instantiate a WIA compatible scanner
|
|
14
|
+
* @constructor
|
|
15
|
+
* @param {string} [baseURL] - Protocol, domain, and port for the service.
|
|
16
|
+
* @example
|
|
17
|
+
* const scanner = new WindowsScanner()
|
|
18
|
+
* const doc = await camera.scan()
|
|
19
|
+
*/
|
|
20
|
+
constructor (baseUrl = BASE_URL) {
|
|
21
|
+
super('capture_scanner_windows', baseUrl)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default WindowsScanner
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head><title>Canon Camera Example</title></head>
|
|
4
|
+
<body>
|
|
5
|
+
<img id="img"/>
|
|
6
|
+
<div>
|
|
7
|
+
<div>
|
|
8
|
+
<label>Rotate</label>
|
|
9
|
+
<input type="number" value="0" id="rotate" min="-360" max="360" step="90"/>
|
|
10
|
+
</div>
|
|
11
|
+
<button type="button" id="capture" title="Capture Image">
|
|
12
|
+
Capture
|
|
13
|
+
</button>
|
|
14
|
+
<button type="button" id="stream" title="Stream Live Feed">
|
|
15
|
+
Stream
|
|
16
|
+
</button>
|
|
17
|
+
</div>
|
|
18
|
+
<script type="module">
|
|
19
|
+
import CanonCamera from '/sdk/js/CanonCamera.js'
|
|
20
|
+
(async () => {
|
|
21
|
+
const defaultSrc = '/demo/img/empty.jpg'
|
|
22
|
+
const defaultWidth = 400
|
|
23
|
+
const img = document.getElementById('img')
|
|
24
|
+
const capture = document.getElementById('capture')
|
|
25
|
+
const stream = document.getElementById('stream')
|
|
26
|
+
const rotation = document.getElementById('rotate')
|
|
27
|
+
|
|
28
|
+
img.src = defaultSrc
|
|
29
|
+
img.width = defaultWidth
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
const camera = new CanonCamera()
|
|
33
|
+
const devices = await camera.devices();
|
|
34
|
+
|
|
35
|
+
if (!devices.length) {
|
|
36
|
+
return alert('No Canon Camera devices found')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Start the first device's live feed and stream it to the img tag
|
|
40
|
+
stream.addEventListener('click', async () => {
|
|
41
|
+
const rotate = parseInt(rotation.value)
|
|
42
|
+
rotation.disabled = true
|
|
43
|
+
stream.disabled = true
|
|
44
|
+
img.src = await camera.streamUrl({rotate})
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
// Take a full capture and add the image to the page
|
|
48
|
+
capture.addEventListener('click', async () => {
|
|
49
|
+
const rotate = parseInt(rotation.value)
|
|
50
|
+
const capture = document.createElement('img')
|
|
51
|
+
img.src = defaultSrc
|
|
52
|
+
capture.src = await camera.takePhoto({rotate})
|
|
53
|
+
capture.width = defaultWidth
|
|
54
|
+
document.body.appendChild(capture)
|
|
55
|
+
rotation.disabled = false
|
|
56
|
+
stream.disabled = false
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
} catch (e) {
|
|
60
|
+
console.error(e)
|
|
61
|
+
alert(`Error: ${e.message}`)
|
|
62
|
+
}
|
|
63
|
+
})()
|
|
64
|
+
</script>
|
|
65
|
+
</body>
|
|
66
|
+
</html>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head><title>Canon Camera Frame Example</title></head>
|
|
4
|
+
<body>
|
|
5
|
+
<div>
|
|
6
|
+
<img id="img"/>
|
|
7
|
+
<div>
|
|
8
|
+
<label>Rotate</label>
|
|
9
|
+
<input type="number" value="0" id="rotate" min="-360" max="360" step="90"/>
|
|
10
|
+
</div>
|
|
11
|
+
<button type="button" id="frame" title="Grab Frame from live feed">
|
|
12
|
+
Get Frame
|
|
13
|
+
</button>
|
|
14
|
+
<button type="button" id="stop" title="Stop live feed">
|
|
15
|
+
Stop Feed
|
|
16
|
+
</button>
|
|
17
|
+
</div>
|
|
18
|
+
<script type="module">
|
|
19
|
+
import CanonCamera from '/sdk/js/CanonCamera.js'
|
|
20
|
+
(async () => {
|
|
21
|
+
const defaultSrc = '/demo/img/empty.jpg'
|
|
22
|
+
const img = document.getElementById('img')
|
|
23
|
+
const rotation = document.getElementById('rotate')
|
|
24
|
+
const frame = document.getElementById('frame')
|
|
25
|
+
const stop = document.getElementById('stop')
|
|
26
|
+
|
|
27
|
+
img.src = defaultSrc
|
|
28
|
+
img.width = 400
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const camera = new CanonCamera()
|
|
32
|
+
const devices = await camera.devices()
|
|
33
|
+
|
|
34
|
+
if (!devices.length) {
|
|
35
|
+
return alert('No Canon Camera devices found')
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Acquiring the first frame will take a few seconds while the camera
|
|
39
|
+
// starts up and begins streaming, subsequent frames will be returned
|
|
40
|
+
// instantaneously
|
|
41
|
+
let lastFrame;
|
|
42
|
+
frame.addEventListener('click', async () => {
|
|
43
|
+
stop.disabled = true
|
|
44
|
+
rotation.disabled = true
|
|
45
|
+
const rotate = parseInt(rotation.value)
|
|
46
|
+
// Cleanup the last frame captured, if any
|
|
47
|
+
if (lastFrame) {
|
|
48
|
+
URL.revokeObjectURL(lastFrame)
|
|
49
|
+
}
|
|
50
|
+
img.src = lastFrame = await camera.getMostRecentFrame({rotate})
|
|
51
|
+
rotation.disabled = false
|
|
52
|
+
stop.disabled = false
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// Stop live feed
|
|
56
|
+
stop.addEventListener('click', async () => {
|
|
57
|
+
const result = await camera.stopFeed()
|
|
58
|
+
alert(result.message || result.status)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.error(e)
|
|
63
|
+
alert(`Error: ${e.message}`)
|
|
64
|
+
}
|
|
65
|
+
})()
|
|
66
|
+
</script>
|
|
67
|
+
</body>
|
|
68
|
+
</html>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head><title>Canon Camera LAN Example</title></head>
|
|
4
|
+
<body>
|
|
5
|
+
<img id="img"/>
|
|
6
|
+
<div>
|
|
7
|
+
<div>
|
|
8
|
+
<label>Rotate</label>
|
|
9
|
+
<input type="number" value="0" id="rotate" min="-360" max="360" step="90"/>
|
|
10
|
+
</div>
|
|
11
|
+
<button type="button" id="capture" title="Capture Image">
|
|
12
|
+
Capture
|
|
13
|
+
</button>
|
|
14
|
+
<button type="button" id="stream" title="Stream Live Feed">
|
|
15
|
+
Stream
|
|
16
|
+
</button>
|
|
17
|
+
</div>
|
|
18
|
+
<script type="module">
|
|
19
|
+
import CanonCamera from '/sdk/js/CanonCamera.js'
|
|
20
|
+
(async () => {
|
|
21
|
+
const defaultSrc = '/demo/img/empty.jpg'
|
|
22
|
+
const defaultWidth = 400
|
|
23
|
+
const img = document.getElementById('img')
|
|
24
|
+
const capture = document.getElementById('capture')
|
|
25
|
+
const stream = document.getElementById('stream')
|
|
26
|
+
const rotation = document.getElementById('rotate')
|
|
27
|
+
|
|
28
|
+
img.src = defaultSrc
|
|
29
|
+
img.width = defaultWidth
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
const defaultURL = 'https://windev2-local.capturebridge.net:9001'
|
|
33
|
+
const url = prompt('Enter remote Base URL', defaultURL)
|
|
34
|
+
const camera = new CanonCamera(url)
|
|
35
|
+
const devices = await camera.devices();
|
|
36
|
+
|
|
37
|
+
if (!devices.length) {
|
|
38
|
+
return alert('No Canon Camera devices found')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Start the first device's live feed and stream it to the img tag
|
|
42
|
+
stream.addEventListener('click', async () => {
|
|
43
|
+
const rotate = parseInt(rotation.value)
|
|
44
|
+
rotation.disabled = true
|
|
45
|
+
stream.disabled = true
|
|
46
|
+
img.src = await camera.streamUrl({rotate})
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// Take a full capture and add the image to the page
|
|
50
|
+
capture.addEventListener('click', async () => {
|
|
51
|
+
const rotate = parseInt(rotation.value)
|
|
52
|
+
const capture = document.createElement('img')
|
|
53
|
+
img.src = defaultSrc
|
|
54
|
+
capture.src = await camera.takePhoto({rotate})
|
|
55
|
+
capture.width = defaultWidth
|
|
56
|
+
document.body.appendChild(capture)
|
|
57
|
+
rotation.disabled = false
|
|
58
|
+
stream.disabled = false
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.error(e)
|
|
63
|
+
alert(`Error: ${e.message}`)
|
|
64
|
+
}
|
|
65
|
+
})()
|
|
66
|
+
</script>
|
|
67
|
+
</body>
|
|
68
|
+
</html>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head><title>Canon Camera Minimal Example</title></head>
|
|
4
|
+
<body>
|
|
5
|
+
<script type="module">
|
|
6
|
+
import CanonCamera from '/sdk/js/CanonCamera.js'
|
|
7
|
+
(async () => {
|
|
8
|
+
try {
|
|
9
|
+
|
|
10
|
+
// Instantiate a Canon Camera
|
|
11
|
+
const camera = new CanonCamera()
|
|
12
|
+
|
|
13
|
+
const devices = await camera.devices();
|
|
14
|
+
|
|
15
|
+
if (!devices.length) {
|
|
16
|
+
return alert('No Canon Camera devices found')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Start the device's live feed and stream it to an img tag
|
|
20
|
+
const img = document.createElement('img')
|
|
21
|
+
img.src = await camera.streamUrl()
|
|
22
|
+
img.height = 400
|
|
23
|
+
document.body.appendChild(img)
|
|
24
|
+
|
|
25
|
+
// Demo live feed for a few seconds, take a picture, and update the img tag
|
|
26
|
+
setTimeout(async () => {
|
|
27
|
+
img.src = await camera.takePhoto()
|
|
28
|
+
}, 9000)
|
|
29
|
+
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.error(e)
|
|
32
|
+
alert(`Error: ${e.message}`)
|
|
33
|
+
}
|
|
34
|
+
})()
|
|
35
|
+
</script>
|
|
36
|
+
</body>
|
|
37
|
+
</html>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head><title>Mock Camera Example</title></head>
|
|
4
|
+
<body>
|
|
5
|
+
<img id="img" src="/demo/img/empty.jpg"/>
|
|
6
|
+
<div>
|
|
7
|
+
<div>
|
|
8
|
+
<label>Rotate</label>
|
|
9
|
+
<input type="number" value="0" id="rotate" min="-360" max="360" step="90"/>
|
|
10
|
+
</div>
|
|
11
|
+
<button type="button" id="capture" title="Capture Image">
|
|
12
|
+
Capture
|
|
13
|
+
</button>
|
|
14
|
+
<button type="button" id="stream" title="Stream Live Feed">
|
|
15
|
+
Stream
|
|
16
|
+
</button>
|
|
17
|
+
</div>
|
|
18
|
+
<script type="module">
|
|
19
|
+
import MockCamera from '/sdk/js/MockCamera.js'
|
|
20
|
+
(async () => {
|
|
21
|
+
const defaultSrc = '/demo/img/empty.jpg'
|
|
22
|
+
const defaultWidth = 400
|
|
23
|
+
const img = document.getElementById('img')
|
|
24
|
+
const capture = document.getElementById('capture')
|
|
25
|
+
const stream = document.getElementById('stream')
|
|
26
|
+
const rotation = document.getElementById('rotate')
|
|
27
|
+
|
|
28
|
+
img.src = defaultSrc
|
|
29
|
+
img.width = defaultWidth
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
const camera = new MockCamera()
|
|
33
|
+
|
|
34
|
+
// Start the first device's live feed and stream it to the img tag
|
|
35
|
+
stream.addEventListener('click', async () => {
|
|
36
|
+
const rotate = parseInt(rotation.value)
|
|
37
|
+
rotation.disabled = true
|
|
38
|
+
stream.disabled = true
|
|
39
|
+
img.src = await camera.streamUrl({rotate})
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
// Take a full capture and add the image to the page
|
|
43
|
+
capture.addEventListener('click', async () => {
|
|
44
|
+
const rotate = parseInt(rotation.value)
|
|
45
|
+
const capture = document.createElement('img')
|
|
46
|
+
img.src = defaultSrc
|
|
47
|
+
capture.src = await camera.takePhoto({rotate})
|
|
48
|
+
capture.width = defaultWidth
|
|
49
|
+
document.body.appendChild(capture)
|
|
50
|
+
rotation.disabled = false
|
|
51
|
+
stream.disabled = false
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
} catch (e) {
|
|
55
|
+
console.error(e)
|
|
56
|
+
alert(`Error: ${e.message}`)
|
|
57
|
+
}
|
|
58
|
+
})()
|
|
59
|
+
</script>
|
|
60
|
+
</body>
|
|
61
|
+
</html>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head><title>Mock Camera Frame Example</title></head>
|
|
4
|
+
<body>
|
|
5
|
+
<div>
|
|
6
|
+
<img id="img"/>
|
|
7
|
+
<div>
|
|
8
|
+
<label>Rotate</label>
|
|
9
|
+
<input type="number" value="0" id="rotate" min="-360" max="360" step="90"/>
|
|
10
|
+
</div>
|
|
11
|
+
<button type="button" id="frame" title="Grab Frame from live feed">
|
|
12
|
+
Get Frame
|
|
13
|
+
</button>
|
|
14
|
+
<button type="button" id="stop" title="Stop live feed">
|
|
15
|
+
Stop Feed
|
|
16
|
+
</button>
|
|
17
|
+
</div>
|
|
18
|
+
<script type="module">
|
|
19
|
+
import MockCamera from '/sdk/js/MockCamera.js'
|
|
20
|
+
(async () => {
|
|
21
|
+
const defaultSrc = '/demo/img/empty.jpg'
|
|
22
|
+
const img = document.getElementById('img')
|
|
23
|
+
const rotation = document.getElementById('rotate')
|
|
24
|
+
const frame = document.getElementById('frame')
|
|
25
|
+
const stop = document.getElementById('stop')
|
|
26
|
+
|
|
27
|
+
img.src = defaultSrc
|
|
28
|
+
img.width = 400
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const camera = new MockCamera()
|
|
32
|
+
const devices = await camera.devices()
|
|
33
|
+
|
|
34
|
+
// Grab a frame from the live feed
|
|
35
|
+
let lastFrame;
|
|
36
|
+
frame.addEventListener('click', async () => {
|
|
37
|
+
stop.disabled = true
|
|
38
|
+
rotation.disabled = true
|
|
39
|
+
const rotate = parseInt(rotation.value)
|
|
40
|
+
// Cleanup the last frame captured, if any
|
|
41
|
+
if (lastFrame) {
|
|
42
|
+
URL.revokeObjectURL(lastFrame)
|
|
43
|
+
}
|
|
44
|
+
img.src = lastFrame = await camera.getMostRecentFrame({rotate})
|
|
45
|
+
document.body.appendChild(frame)
|
|
46
|
+
rotation.disabled = false
|
|
47
|
+
stop.disabled = false
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// Stop live feed
|
|
51
|
+
stop.addEventListener('click', async () => {
|
|
52
|
+
const result = await camera.stopFeed()
|
|
53
|
+
alert(result.message || result.status)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.error(e)
|
|
58
|
+
alert(`Error: ${e.message}`)
|
|
59
|
+
}
|
|
60
|
+
})()
|
|
61
|
+
</script>
|
|
62
|
+
</body>
|
|
63
|
+
</html>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head><title>Mock Camera Minimal Example</title></head>
|
|
4
|
+
<body>
|
|
5
|
+
<script type="module">
|
|
6
|
+
import MockCamera from '/sdk/js/MockCamera.js'
|
|
7
|
+
(async () => {
|
|
8
|
+
try {
|
|
9
|
+
|
|
10
|
+
// Instantiate a Mock Camera
|
|
11
|
+
const camera = new MockCamera()
|
|
12
|
+
|
|
13
|
+
// Start the device's live feed and stream it to an img tag
|
|
14
|
+
const img = document.createElement('img')
|
|
15
|
+
img.src = await camera.streamUrl()
|
|
16
|
+
img.height = 400
|
|
17
|
+
document.body.appendChild(img)
|
|
18
|
+
|
|
19
|
+
// Demo live feed for a few seconds, take a picture, and update the img tag
|
|
20
|
+
setTimeout(async () => {
|
|
21
|
+
img.src = await camera.takePhoto()
|
|
22
|
+
}, 9000)
|
|
23
|
+
|
|
24
|
+
} catch (e) {
|
|
25
|
+
console.error(e)
|
|
26
|
+
alert(`Error: ${e.message}`)
|
|
27
|
+
}
|
|
28
|
+
})()
|
|
29
|
+
</script>
|
|
30
|
+
</body>
|
|
31
|
+
</html>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head><title>Windows Scanner Example</title></head>
|
|
4
|
+
<body>
|
|
5
|
+
<img id="img"/>
|
|
6
|
+
<script type="module">
|
|
7
|
+
import WindowsScanner from '/sdk/js/WindowsScanner.js'
|
|
8
|
+
(async () => {
|
|
9
|
+
try {
|
|
10
|
+
|
|
11
|
+
const scanner = new WindowsScanner()
|
|
12
|
+
|
|
13
|
+
const devices = await scanner.devices();
|
|
14
|
+
|
|
15
|
+
if (!devices.length) {
|
|
16
|
+
return alert('No Scanner devices found')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let scan = await scanner.scan()
|
|
20
|
+
|
|
21
|
+
document.createElement('img')
|
|
22
|
+
img.src = await scanner.scan()
|
|
23
|
+
document.body.appendChild(img)
|
|
24
|
+
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error(e)
|
|
27
|
+
alert(`Error: ${e.message}`)
|
|
28
|
+
}
|
|
29
|
+
})()
|
|
30
|
+
</script>
|
|
31
|
+
</body>
|
|
32
|
+
</html>
|