@zappar/zappar-cv 3.0.0-alpha.3 → 3.0.0-alpha.4

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/README.md CHANGED
@@ -18,8 +18,8 @@ npm i @zappar/zappar-cv
18
18
 
19
19
  You can use our CDN from within your HTML:
20
20
  ```
21
- <script src="https://libs.zappar.com/zappar-cv/3.0.0-alpha.3/zappar-cv.js"></script>
21
+ <script src="https://libs.zappar.com/zappar-cv/3.0.0-alpha.4/zappar-cv.js"></script>
22
22
  ```
23
23
 
24
24
  Or you can download and host our standalone JavaScript bundle:
25
- [https://libs.zappar.com/zappar-cv/3.0.0-alpha.3/zappar-cv.zip](https://libs.zappar.com/zappar-cv/3.0.0-alpha.3/zappar-cv.zip)
25
+ [https://libs.zappar.com/zappar-cv/3.0.0-alpha.4/zappar-cv.zip](https://libs.zappar.com/zappar-cv/3.0.0-alpha.4/zappar-cv.zip)
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "3.0.0-alpha.3";
1
+ export declare const VERSION = "3.0.0-alpha.4";
package/lib/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "3.0.0-alpha.3";
1
+ export const VERSION = "3.0.0-alpha.4";
@@ -129,13 +129,22 @@ export function launchWorkerServer(wasmUrl) {
129
129
  function consumeStream(mod, r, stream, p, userFacing, server, source) {
130
130
  return __awaiter(this, void 0, void 0, function* () {
131
131
  while (true) {
132
+ let reader;
133
+ try {
134
+ reader = yield stream.getReader();
135
+ }
136
+ catch (err) {
137
+ console.log("Error getting reader", err);
138
+ yield delay(1000);
139
+ continue;
140
+ }
132
141
  try {
133
- const reader = yield stream.getReader();
134
142
  yield consumeReader(mod, r, reader, p, userFacing, server, source);
135
143
  }
136
144
  catch (err) {
137
145
  console.log("Consuming reader error", err);
138
146
  }
147
+ reader.releaseLock();
139
148
  yield delay(1000);
140
149
  }
141
150
  });
@@ -143,12 +152,24 @@ function consumeStream(mod, r, stream, p, userFacing, server, source) {
143
152
  let streamDataBufferPointer = 0;
144
153
  let streamDataBufferLength = 0;
145
154
  let tokenId = 1;
155
+ function getFrameOrTimeout(reader) {
156
+ return new Promise((resolve, reject) => {
157
+ const token = setTimeout(() => {
158
+ console.log('Frame timeout');
159
+ reject();
160
+ }, 2000);
161
+ reader.read().then(result => {
162
+ clearTimeout(token);
163
+ resolve(result);
164
+ });
165
+ });
166
+ }
146
167
  const cameraToDeviceTransform = mat4.create();
147
168
  const cameraModel = new Float32Array([300, 300, 160, 120, 0, 0]);
148
169
  function consumeReader(mod, r, reader, p, userFacing, server, source) {
149
170
  return __awaiter(this, void 0, void 0, function* () {
150
171
  while (true) {
151
- let result = yield reader.read();
172
+ let result = yield getFrameOrTimeout(reader);
152
173
  if (result.done) {
153
174
  console.log("Stream done");
154
175
  return;
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zappar/zappar-cv",
3
- "version": "3.0.0-alpha.3",
3
+ "version": "3.0.0-alpha.4",
4
4
  "description": "Zappar's core computer vision library, supporting image, face and world tracking.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",