@capturebridge/sdk 0.11.5 → 0.12.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/CHANGELOG.md +7 -0
- package/Common.js +9 -2
- package/Version.js +7 -7
- package/package.json +8 -8
- package/examples/canon.html +0 -20
- package/examples/canon.js +0 -44
- package/examples/canon_getframe.html +0 -20
- package/examples/canon_getframe.js +0 -46
- package/examples/canon_lan.html +0 -20
- package/examples/canon_lan.js +0 -46
- package/examples/canon_minimal.html +0 -7
- package/examples/canon_minimal.js +0 -27
- package/examples/empty.jpg +0 -0
- package/examples/icao.html +0 -7
- package/examples/icao.jpg +0 -0
- package/examples/icao.js +0 -80
- package/examples/mockcamera.html +0 -20
- package/examples/mockcamera.js +0 -39
- package/examples/mockcamera_getframe.html +0 -20
- package/examples/mockcamera_getframe.js +0 -40
- package/examples/mockcamera_minimal.html +0 -7
- package/examples/mockcamera_minimal.js +0 -21
- package/examples/verifone_signature.html +0 -7
- package/examples/verifone_signature.js +0 -14
- package/examples/windows_scanner_minimal.html +0 -8
- package/examples/windows_scanner_minimal.js +0 -19
- package/types.d.ts +0 -126
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.12.0] - 2024-08-08
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- `BASE_URL` will default to `window.location.origin` if available, else
|
|
13
|
+
https://local.capturebridge.net:9001) will be used.
|
|
14
|
+
|
|
8
15
|
## [0.11.4] - 2024-07-29
|
|
9
16
|
|
|
10
17
|
### Added
|
package/Common.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @summary Default
|
|
2
|
+
* @summary Default URL for API requests.
|
|
3
|
+
* @constant
|
|
4
|
+
* @type {string}
|
|
5
|
+
*/
|
|
6
|
+
export const DEFAULT_URL = 'https://local.capturebridge.net:9001'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @summary Base URL for API requests.
|
|
3
10
|
* @constant
|
|
4
11
|
* @type {string}
|
|
5
12
|
* @default {@link https://local.capturebridge.net:9001}
|
|
6
13
|
*/
|
|
7
|
-
export const BASE_URL =
|
|
14
|
+
export const BASE_URL = window?.location?.origin ?? DEFAULT_URL
|
|
8
15
|
|
|
9
16
|
/**
|
|
10
17
|
* Common {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API|Fetch}
|
package/Version.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @summary SDK Version as published on
|
|
3
|
-
* {@link https://www.npmjs.com/package/@capturebridge/sdk|NPM}
|
|
4
|
-
* @constant
|
|
5
|
-
* @type {string}
|
|
6
|
-
*/
|
|
7
|
-
const VERSION = '0.
|
|
1
|
+
/**
|
|
2
|
+
* @summary SDK Version as published on
|
|
3
|
+
* {@link https://www.npmjs.com/package/@capturebridge/sdk|NPM}
|
|
4
|
+
* @constant
|
|
5
|
+
* @type {string}
|
|
6
|
+
*/
|
|
7
|
+
const VERSION = '0.12.1'
|
|
8
8
|
export default VERSION
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@capturebridge/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Capture Bridge JavaScript SDK for web applications",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"types": "types.d.ts",
|
|
7
|
-
"license": "Apache-2.0"
|
|
8
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@capturebridge/sdk",
|
|
3
|
+
"version": "0.12.1",
|
|
4
|
+
"description": "Capture Bridge JavaScript SDK for web applications",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "types.d.ts",
|
|
7
|
+
"license": "Apache-2.0"
|
|
8
|
+
}
|
package/examples/canon.html
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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" src="./canon.js"></script>
|
|
19
|
-
</body>
|
|
20
|
-
</html>
|
package/examples/canon.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import CanonCamera from '../../../../sdk/js/CanonCamera.js'
|
|
2
|
-
(async () => {
|
|
3
|
-
const defaultSrc = 'empty.jpg'
|
|
4
|
-
const defaultWidth = 400
|
|
5
|
-
const img = document.getElementById('img')
|
|
6
|
-
const capture = document.getElementById('capture')
|
|
7
|
-
const stream = document.getElementById('stream')
|
|
8
|
-
const rotation = document.getElementById('rotate')
|
|
9
|
-
|
|
10
|
-
img.src = defaultSrc
|
|
11
|
-
img.width = defaultWidth
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const camera = new CanonCamera()
|
|
15
|
-
const devices = await camera.devices()
|
|
16
|
-
|
|
17
|
-
if (!devices.length) {
|
|
18
|
-
return window.alert('No Canon Camera devices found')
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Start the first device's live feed and stream it to the img tag
|
|
22
|
-
stream.addEventListener('click', async () => {
|
|
23
|
-
const rotate = parseInt(rotation.value)
|
|
24
|
-
rotation.disabled = true
|
|
25
|
-
stream.disabled = true
|
|
26
|
-
img.src = await camera.streamUrl({ rotate })
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
// Take a full capture and add the image to the page
|
|
30
|
-
capture.addEventListener('click', async () => {
|
|
31
|
-
const rotate = parseInt(rotation.value)
|
|
32
|
-
const capture = document.createElement('img')
|
|
33
|
-
img.src = defaultSrc
|
|
34
|
-
capture.src = await camera.takePhoto({ rotate })
|
|
35
|
-
capture.width = defaultWidth
|
|
36
|
-
document.body.appendChild(capture)
|
|
37
|
-
rotation.disabled = false
|
|
38
|
-
stream.disabled = false
|
|
39
|
-
})
|
|
40
|
-
} catch (e) {
|
|
41
|
-
console.error(e)
|
|
42
|
-
window.alert(`Error: ${e.message}`)
|
|
43
|
-
}
|
|
44
|
-
})()
|
|
@@ -1,20 +0,0 @@
|
|
|
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" src="./canon_getframe.js"></script>
|
|
19
|
-
</body>
|
|
20
|
-
</html>
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import CanonCamera from '../../../../sdk/js/CanonCamera.js'
|
|
2
|
-
(async () => {
|
|
3
|
-
const defaultSrc = 'empty.jpg'
|
|
4
|
-
const img = document.getElementById('img')
|
|
5
|
-
const rotation = document.getElementById('rotate')
|
|
6
|
-
const frame = document.getElementById('frame')
|
|
7
|
-
const stop = document.getElementById('stop')
|
|
8
|
-
|
|
9
|
-
img.src = defaultSrc
|
|
10
|
-
img.width = 400
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
const camera = new CanonCamera()
|
|
14
|
-
const devices = await camera.devices()
|
|
15
|
-
|
|
16
|
-
if (!devices.length) {
|
|
17
|
-
return window.alert('No Canon Camera devices found')
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Acquiring the first frame will take a few seconds while the camera
|
|
21
|
-
// starts up and begins streaming, subsequent frames will be returned
|
|
22
|
-
// instantaneously
|
|
23
|
-
let lastFrame
|
|
24
|
-
frame.addEventListener('click', async () => {
|
|
25
|
-
stop.disabled = true
|
|
26
|
-
rotation.disabled = true
|
|
27
|
-
const rotate = parseInt(rotation.value)
|
|
28
|
-
// Cleanup the last frame captured, if any
|
|
29
|
-
if (lastFrame) {
|
|
30
|
-
URL.revokeObjectURL(lastFrame)
|
|
31
|
-
}
|
|
32
|
-
img.src = lastFrame = await camera.getMostRecentFrame({ rotate })
|
|
33
|
-
rotation.disabled = false
|
|
34
|
-
stop.disabled = false
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
// Stop live feed
|
|
38
|
-
stop.addEventListener('click', async () => {
|
|
39
|
-
const result = await camera.stopFeed()
|
|
40
|
-
window.alert(result.message || result.status)
|
|
41
|
-
})
|
|
42
|
-
} catch (e) {
|
|
43
|
-
console.error(e)
|
|
44
|
-
window.alert(`Error: ${e.message}`)
|
|
45
|
-
}
|
|
46
|
-
})()
|
package/examples/canon_lan.html
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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" src="./canon_lan.js"></script>
|
|
19
|
-
</body>
|
|
20
|
-
</html>
|
package/examples/canon_lan.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import CanonCamera from '../../../../sdk/js/CanonCamera.js'
|
|
2
|
-
(async () => {
|
|
3
|
-
const defaultSrc = 'empty.jpg'
|
|
4
|
-
const defaultWidth = 400
|
|
5
|
-
const img = document.getElementById('img')
|
|
6
|
-
const capture = document.getElementById('capture')
|
|
7
|
-
const stream = document.getElementById('stream')
|
|
8
|
-
const rotation = document.getElementById('rotate')
|
|
9
|
-
|
|
10
|
-
img.src = defaultSrc
|
|
11
|
-
img.width = defaultWidth
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const defaultURL = 'https://windev2-local.capturebridge.net:9001'
|
|
15
|
-
const url = window.prompt('Enter remote Base URL', defaultURL)
|
|
16
|
-
const camera = new CanonCamera(url)
|
|
17
|
-
const devices = await camera.devices()
|
|
18
|
-
|
|
19
|
-
if (!devices.length) {
|
|
20
|
-
return window.alert('No Canon Camera devices found')
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Start the first device's live feed and stream it to the img tag
|
|
24
|
-
stream.addEventListener('click', async () => {
|
|
25
|
-
const rotate = parseInt(rotation.value)
|
|
26
|
-
rotation.disabled = true
|
|
27
|
-
stream.disabled = true
|
|
28
|
-
img.src = await camera.streamUrl({ rotate })
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
// Take a full capture and add the image to the page
|
|
32
|
-
capture.addEventListener('click', async () => {
|
|
33
|
-
const rotate = parseInt(rotation.value)
|
|
34
|
-
const capture = document.createElement('img')
|
|
35
|
-
img.src = defaultSrc
|
|
36
|
-
capture.src = await camera.takePhoto({ rotate })
|
|
37
|
-
capture.width = defaultWidth
|
|
38
|
-
document.body.appendChild(capture)
|
|
39
|
-
rotation.disabled = false
|
|
40
|
-
stream.disabled = false
|
|
41
|
-
})
|
|
42
|
-
} catch (e) {
|
|
43
|
-
console.error(e)
|
|
44
|
-
window.alert(`Error: ${e.message}`)
|
|
45
|
-
}
|
|
46
|
-
})()
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import CanonCamera from '../../../../sdk/js/CanonCamera.js'
|
|
2
|
-
(async () => {
|
|
3
|
-
try {
|
|
4
|
-
// Instantiate a Canon Camera
|
|
5
|
-
const camera = new CanonCamera()
|
|
6
|
-
|
|
7
|
-
const devices = await camera.devices()
|
|
8
|
-
|
|
9
|
-
if (!devices.length) {
|
|
10
|
-
return window.alert('No Canon Camera devices found')
|
|
11
|
-
}
|
|
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
|
-
} catch (e) {
|
|
24
|
-
console.error(e)
|
|
25
|
-
window.alert(`Error: ${e.message}`)
|
|
26
|
-
}
|
|
27
|
-
})()
|
package/examples/empty.jpg
DELETED
|
Binary file
|
package/examples/icao.html
DELETED
package/examples/icao.jpg
DELETED
|
Binary file
|
package/examples/icao.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import ICAO from '../../../../sdk/js/ICAO.js'
|
|
2
|
-
import ImageSource from '../../../../sdk/js/ImageSource.js'
|
|
3
|
-
|
|
4
|
-
(async () => {
|
|
5
|
-
try {
|
|
6
|
-
const icao = new ICAO()
|
|
7
|
-
const imgSrc = new ImageSource('icao.jpg', 'url')
|
|
8
|
-
|
|
9
|
-
// Perform an ICAO check against the provided Image and return cropped
|
|
10
|
-
const results = await icao.check(imgSrc, true, '#a5a5a5')
|
|
11
|
-
|
|
12
|
-
// Our stock photo is zoomed in too close, so we pad the canvas to allow for
|
|
13
|
-
// drawing a box around the cropped portion
|
|
14
|
-
const padding = 150
|
|
15
|
-
|
|
16
|
-
// stroke/arc color
|
|
17
|
-
const color = 'rgba(0,255,0,0.5)'
|
|
18
|
-
|
|
19
|
-
// Load the image and draw it on a Canvas
|
|
20
|
-
const img = await imgSrc.toImage()
|
|
21
|
-
const canvas = document.createElement('canvas')
|
|
22
|
-
const ctx = canvas.getContext('2d')
|
|
23
|
-
canvas.width = img.width + padding
|
|
24
|
-
canvas.height = img.height + padding
|
|
25
|
-
ctx.drawImage(img, padding / 2, padding / 2, img.width, img.height)
|
|
26
|
-
|
|
27
|
-
document.body.appendChild(canvas)
|
|
28
|
-
|
|
29
|
-
ctx.strokeStyle = color
|
|
30
|
-
ctx.lineWidth = 4
|
|
31
|
-
|
|
32
|
-
// Insert cropped image into the DOM
|
|
33
|
-
const croppedSrc = new ImageSource(results.cropped)
|
|
34
|
-
document.body.appendChild(await croppedSrc.toImage())
|
|
35
|
-
|
|
36
|
-
// Draw points for left and right eye
|
|
37
|
-
ctx.beginPath()
|
|
38
|
-
ctx.arc(results.face.left_eye.x + padding / 2,
|
|
39
|
-
results.face.left_eye.y + padding / 2, 5, 0, 2 * Math.PI)
|
|
40
|
-
ctx.fillStyle = color
|
|
41
|
-
ctx.fill()
|
|
42
|
-
|
|
43
|
-
ctx.beginPath()
|
|
44
|
-
ctx.arc(results.face.right_eye.x + padding / 2,
|
|
45
|
-
results.face.right_eye.y + padding / 2, 5, 0, 2 * Math.PI)
|
|
46
|
-
ctx.fillStyle = color
|
|
47
|
-
ctx.fill()
|
|
48
|
-
|
|
49
|
-
// Draw bounding box where image was cropped
|
|
50
|
-
ctx.beginPath()
|
|
51
|
-
ctx.moveTo(results.crop_boundary[0].x + padding / 2,
|
|
52
|
-
results.crop_boundary[0].y + padding / 2)
|
|
53
|
-
for (let i = 1; i < results.crop_boundary.length; i++) {
|
|
54
|
-
ctx.lineTo(results.crop_boundary[i].x + padding / 2,
|
|
55
|
-
results.crop_boundary[i].y + padding / 2)
|
|
56
|
-
}
|
|
57
|
-
ctx.closePath()
|
|
58
|
-
ctx.stroke()
|
|
59
|
-
|
|
60
|
-
// Display ICAO attributes
|
|
61
|
-
const output = document.createElement('textarea')
|
|
62
|
-
output.style.display = 'block'
|
|
63
|
-
output.rows = 35
|
|
64
|
-
output.cols = 50
|
|
65
|
-
output.value = '# Checks\n\n'
|
|
66
|
-
document.body.appendChild(output)
|
|
67
|
-
results.attributes.filter(attr => attr.type === 'check').forEach(({ id, score, compliant }) => {
|
|
68
|
-
output.value += (compliant ? '✅' : '❌') + `${id}: ${score}\n`
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
output.value += '\n\n# Data\n\n'
|
|
72
|
-
|
|
73
|
-
results.attributes.filter(attr => attr.type === 'data').forEach(({ id, score, data }) => {
|
|
74
|
-
output.value += `${id}: ${data || score}\n`
|
|
75
|
-
})
|
|
76
|
-
} catch (e) {
|
|
77
|
-
console.error(e)
|
|
78
|
-
window.alert(`Error: ${e.message}`)
|
|
79
|
-
}
|
|
80
|
-
})()
|
package/examples/mockcamera.html
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head><title>Mock Camera Example</title></head>
|
|
4
|
-
<body>
|
|
5
|
-
<img id="img" src="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" src="./mockcamera.js"></script>
|
|
19
|
-
</body>
|
|
20
|
-
</html>
|
package/examples/mockcamera.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import MockCamera from '../../../../sdk/js/MockCamera.js'
|
|
2
|
-
(async () => {
|
|
3
|
-
const defaultSrc = 'empty.jpg'
|
|
4
|
-
const defaultWidth = 400
|
|
5
|
-
const img = document.getElementById('img')
|
|
6
|
-
const capture = document.getElementById('capture')
|
|
7
|
-
const stream = document.getElementById('stream')
|
|
8
|
-
const rotation = document.getElementById('rotate')
|
|
9
|
-
|
|
10
|
-
img.src = defaultSrc
|
|
11
|
-
img.width = defaultWidth
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const camera = new MockCamera()
|
|
15
|
-
|
|
16
|
-
// Start the first device's live feed and stream it to the img tag
|
|
17
|
-
stream.addEventListener('click', async () => {
|
|
18
|
-
const rotate = parseInt(rotation.value)
|
|
19
|
-
rotation.disabled = true
|
|
20
|
-
stream.disabled = true
|
|
21
|
-
img.src = await camera.streamUrl({ rotate })
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
// Take a full capture and add the image to the page
|
|
25
|
-
capture.addEventListener('click', async () => {
|
|
26
|
-
const rotate = parseInt(rotation.value)
|
|
27
|
-
const capture = document.createElement('img')
|
|
28
|
-
img.src = defaultSrc
|
|
29
|
-
capture.src = await camera.takePhoto({ rotate })
|
|
30
|
-
capture.width = defaultWidth
|
|
31
|
-
document.body.appendChild(capture)
|
|
32
|
-
rotation.disabled = false
|
|
33
|
-
stream.disabled = false
|
|
34
|
-
})
|
|
35
|
-
} catch (e) {
|
|
36
|
-
console.error(e)
|
|
37
|
-
window.alert(`Error: ${e.message}`)
|
|
38
|
-
}
|
|
39
|
-
})()
|
|
@@ -1,20 +0,0 @@
|
|
|
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" src="./mockcamera_getframe.js"></script>
|
|
19
|
-
</body>
|
|
20
|
-
</html>
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import MockCamera from '../../../../sdk/js/MockCamera.js'
|
|
2
|
-
(async () => {
|
|
3
|
-
const defaultSrc = 'empty.jpg'
|
|
4
|
-
const img = document.getElementById('img')
|
|
5
|
-
const rotation = document.getElementById('rotate')
|
|
6
|
-
const frame = document.getElementById('frame')
|
|
7
|
-
const stop = document.getElementById('stop')
|
|
8
|
-
|
|
9
|
-
img.src = defaultSrc
|
|
10
|
-
img.width = 400
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
const camera = new MockCamera()
|
|
14
|
-
|
|
15
|
-
// Grab a frame from the live feed
|
|
16
|
-
let lastFrame
|
|
17
|
-
frame.addEventListener('click', async () => {
|
|
18
|
-
stop.disabled = true
|
|
19
|
-
rotation.disabled = true
|
|
20
|
-
const rotate = parseInt(rotation.value)
|
|
21
|
-
// Cleanup the last frame captured, if any
|
|
22
|
-
if (lastFrame) {
|
|
23
|
-
URL.revokeObjectURL(lastFrame)
|
|
24
|
-
}
|
|
25
|
-
img.src = lastFrame = await camera.getMostRecentFrame({ rotate })
|
|
26
|
-
document.body.appendChild(frame)
|
|
27
|
-
rotation.disabled = false
|
|
28
|
-
stop.disabled = false
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
// Stop live feed
|
|
32
|
-
stop.addEventListener('click', async () => {
|
|
33
|
-
const result = await camera.stopFeed()
|
|
34
|
-
window.alert(result.message || result.status)
|
|
35
|
-
})
|
|
36
|
-
} catch (e) {
|
|
37
|
-
console.error(e)
|
|
38
|
-
window.alert(`Error: ${e.message}`)
|
|
39
|
-
}
|
|
40
|
-
})()
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import MockCamera from '../../../../sdk/js/MockCamera.js'
|
|
2
|
-
(async () => {
|
|
3
|
-
try {
|
|
4
|
-
// Instantiate a Mock Camera
|
|
5
|
-
const camera = new MockCamera()
|
|
6
|
-
|
|
7
|
-
// Start the device's live feed and stream it to an img tag
|
|
8
|
-
const img = document.createElement('img')
|
|
9
|
-
img.src = await camera.streamUrl()
|
|
10
|
-
img.height = 400
|
|
11
|
-
document.body.appendChild(img)
|
|
12
|
-
|
|
13
|
-
// Demo live feed for a few seconds, take a picture, and update the img tag
|
|
14
|
-
setTimeout(async () => {
|
|
15
|
-
img.src = await camera.takePhoto()
|
|
16
|
-
}, 9000)
|
|
17
|
-
} catch (e) {
|
|
18
|
-
console.error(e)
|
|
19
|
-
window.alert(`Error: ${e.message}`)
|
|
20
|
-
}
|
|
21
|
-
})()
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import Verifone from '../../../../sdk/js/Verifone.js'
|
|
2
|
-
(async () => {
|
|
3
|
-
try {
|
|
4
|
-
const tablet = new Verifone()
|
|
5
|
-
|
|
6
|
-
const img = document.createElement('img')
|
|
7
|
-
img.src = await tablet.signature({ format: 'jpg' })
|
|
8
|
-
await tablet.clear()
|
|
9
|
-
document.body.appendChild(img)
|
|
10
|
-
} catch (e) {
|
|
11
|
-
console.error(e)
|
|
12
|
-
window.alert(`Error: ${e.message}`)
|
|
13
|
-
}
|
|
14
|
-
})()
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import WindowsScanner from '../../../../sdk/js/WindowsScanner.js'
|
|
2
|
-
(async () => {
|
|
3
|
-
try {
|
|
4
|
-
const scanner = new WindowsScanner()
|
|
5
|
-
|
|
6
|
-
const devices = await scanner.devices()
|
|
7
|
-
|
|
8
|
-
if (!devices.length) {
|
|
9
|
-
return window.alert('No Scanner devices found')
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const img = document.createElement('img')
|
|
13
|
-
img.src = await scanner.scan()
|
|
14
|
-
document.body.appendChild(img)
|
|
15
|
-
} catch (e) {
|
|
16
|
-
console.error(e)
|
|
17
|
-
window.alert(`Error: ${e.message}`)
|
|
18
|
-
}
|
|
19
|
-
})()
|
package/types.d.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
declare module '@capturebridge/sdk/Camera' {
|
|
3
|
-
const Camera: any;
|
|
4
|
-
export default Camera;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare module '@capturebridge/sdk/CanonCamera' {
|
|
8
|
-
const CanonCamera: any;
|
|
9
|
-
export default CanonCamera;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare module '@capturebridge/sdk/CaptureBridge' {
|
|
13
|
-
const CaptureBridge: any;
|
|
14
|
-
export default CaptureBridge;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
declare module '@capturebridge/sdk/CapturePlugin' {
|
|
18
|
-
const CapturePlugin: any;
|
|
19
|
-
export default CapturePlugin;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare module '@capturebridge/sdk/Device' {
|
|
23
|
-
const Device: any;
|
|
24
|
-
export default Device;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
declare module '@capturebridge/sdk/ICAO' {
|
|
28
|
-
const ICAO: any;
|
|
29
|
-
export default ICAO;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
declare module '@capturebridge/sdk/Probe' {
|
|
33
|
-
const Probe: any;
|
|
34
|
-
export default Probe;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
declare module '@capturebridge/sdk/Candidate' {
|
|
38
|
-
const Candidate: any;
|
|
39
|
-
export default Candidate;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
declare module '@capturebridge/sdk/IFace' {
|
|
43
|
-
const IFace: any;
|
|
44
|
-
export default IFace;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
declare module '@capturebridge/sdk/ImageSource' {
|
|
48
|
-
const ImageSource: any;
|
|
49
|
-
export default ImageSource;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
declare module '@capturebridge/sdk/Logs' {
|
|
53
|
-
const Logs: any;
|
|
54
|
-
export default Logs;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
declare module '@capturebridge/sdk/MockCamera' {
|
|
58
|
-
const MockCamera: any;
|
|
59
|
-
export default MockCamera;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
declare module '@capturebridge/sdk/Plugin' {
|
|
63
|
-
const Plugin: any;
|
|
64
|
-
export default Plugin;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
declare module '@capturebridge/sdk/Scanner' {
|
|
68
|
-
const Scanner: any;
|
|
69
|
-
export default Scanner;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
declare module '@capturebridge/sdk/SignatureTablet' {
|
|
73
|
-
const SignatureTablet: any;
|
|
74
|
-
export default SignatureTablet;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
declare module '@capturebridge/sdk/DisplayWidget' {
|
|
78
|
-
const DisplayWidget: any;
|
|
79
|
-
export default DisplayWidget;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
declare module '@capturebridge/sdk/TextButton' {
|
|
83
|
-
const TextButton: any;
|
|
84
|
-
export default TextButton;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
declare module '@capturebridge/sdk/Text' {
|
|
88
|
-
const Text: any;
|
|
89
|
-
export default Text;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
declare module '@capturebridge/sdk/Image' {
|
|
93
|
-
const Image: any;
|
|
94
|
-
export default Image;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
declare module '@capturebridge/sdk/StreamingCapturePlugin' {
|
|
98
|
-
const StreamingCapturePlugin: any;
|
|
99
|
-
export default StreamingCapturePlugin;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
declare module '@capturebridge/sdk/TopazSigGem' {
|
|
103
|
-
const TopazSigGem: any;
|
|
104
|
-
export default TopazSigGem;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
declare module '@capturebridge/sdk/ControlProperty' {
|
|
108
|
-
const ControlProperty: any;
|
|
109
|
-
export default ControlProperty;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
declare module '@capturebridge/sdk/DeviceForm' {
|
|
113
|
-
const DeviceForm: any;
|
|
114
|
-
export default DeviceForm;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
declare module '@capturebridge/sdk/Verifone' {
|
|
118
|
-
const Verifone: any;
|
|
119
|
-
export default Verifone;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
declare module '@capturebridge/sdk/WindowsScanner' {
|
|
123
|
-
const WindowsScanner: any;
|
|
124
|
-
export default WindowsScanner;
|
|
125
|
-
}
|
|
126
|
-
|