diff --git a/CHANGELOG.md b/CHANGELOG.md index c557d467..631d2110 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,11 +9,12 @@ Repository: **** ## Changelog +### **HEAD -> main** 2021/08/12 mandic00@live.com + + ### **2.1.3** 2021/08/12 mandic00@live.com - -### **origin/main** 2021/08/11 mandic00@live.com - +- fix centernet & update blazeface - minor update - replace movenet with lightning-v4 - enable webgl uniform support for faster warmup diff --git a/demo/nodejs/node-webcam.js b/demo/nodejs/node-webcam.js index a55bfded..109230fc 100644 --- a/demo/nodejs/node-webcam.js +++ b/demo/nodejs/node-webcam.js @@ -7,6 +7,7 @@ */ const util = require('util'); +const process = require('process'); const log = require('@vladmandic/pilogger'); // eslint-disable-next-line node/no-missing-require const nodeWebCam = require('node-webcam'); @@ -21,19 +22,31 @@ const optionsCamera = { callbackReturn: 'buffer', // this means whatever `fswebcam` writes to disk, no additional processing so it's fastest saveShots: false, // don't save processed frame to disk, note that temp file is still created by fswebcam thus recommendation for tmpfs }; +const camera = nodeWebCam.create(optionsCamera); // options for human const optionsHuman = { backend: 'tensorflow', modelBasePath: 'file://models/', }; - -const camera = nodeWebCam.create(optionsCamera); -const capture = util.promisify(camera.capture); const human = new Human(optionsHuman); + const results = []; +const list = util.promisify(camera.list); +const capture = util.promisify(camera.capture); + +async function init() { + try { + const found = await list(); + log.data('Camera data:', found); + } catch { + log.error('Could not access camera'); + process.exit(1); + } +} const buffer2tensor = human.tf.tidy((buffer) => { + if (!buffer) return null; const decode = human.tf.node.decodeImage(buffer, 3); let expand; if (decode.shape[2] === 4) { // input is in rgba format, need to convert to rgb @@ -47,24 +60,30 @@ const buffer2tensor = human.tf.tidy((buffer) => { return cast; }); -async function process() { +async function detect() { // trigger next frame every 5 sec // triggered here before actual capture and detection since we assume it will complete in less than 5sec // so it's as close as possible to real 5sec and not 5sec + detection time // if there is a chance of race scenario where detection takes longer than loop trigger, then trigger should be at the end of the function instead - setTimeout(() => process(), 5000); + setTimeout(() => detect(), 5000); const buffer = await capture(); // gets the (default) jpeg data from from webcam const tensor = buffer2tensor(buffer); // create tensor from image buffer - const res = await human.detect(tensor); // run detection - - // do whatever here with the res - // or just append it to results array that will contain all processed results over time - results.push(res); + if (tensor) { + const res = await human.detect(tensor); // run detection + // do whatever here with the res + // or just append it to results array that will contain all processed results over time + results.push(res); + } // alternatively to triggering every 5sec sec, simply trigger next frame as fast as possible // setImmediate(() => process()); } +async function main() { + await init(); + detect(); +} + log.header(); -process(); +main(); diff --git a/package.json b/package.json index 78a685f3..1de4846a 100644 --- a/package.json +++ b/package.json @@ -66,14 +66,14 @@ "@tensorflow/tfjs-layers": "^3.8.0", "@tensorflow/tfjs-node": "^3.8.0", "@tensorflow/tfjs-node-gpu": "^3.8.0", - "@types/node": "^16.6.0", + "@types/node": "^16.6.1", "@typescript-eslint/eslint-plugin": "^4.29.1", "@typescript-eslint/parser": "^4.29.1", "@vladmandic/pilogger": "^0.2.18", "canvas": "^2.8.0", "chokidar": "^3.5.2", "dayjs": "^1.10.6", - "esbuild": "^0.12.19", + "esbuild": "^0.12.20", "eslint": "^7.32.0", "eslint-config-airbnb-base": "^14.2.1", "eslint-plugin-import": "^2.24.0", @@ -83,7 +83,7 @@ "node-fetch": "^2.6.1", "rimraf": "^3.0.2", "seedrandom": "^3.0.5", - "simple-git": "^2.42.0", + "simple-git": "^2.43.0", "tslib": "^2.3.1", "typedoc": "0.21.5", "typescript": "4.3.5" diff --git a/server/build.log b/server/build.log index e2520080..4bda32f4 100644 --- a/server/build.log +++ b/server/build.log @@ -1,22 +1,22 @@ -2021-08-12 09:29:51 INFO:  @vladmandic/human version 2.1.3 -2021-08-12 09:29:51 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.5.0 -2021-08-12 09:29:51 INFO:  Toolchain: {"tfjs":"3.8.0","esbuild":"0.12.19","typescript":"4.3.5","typedoc":"0.21.5","eslint":"7.32.0"} -2021-08-12 09:29:51 INFO:  Clean: ["dist/*","types/*","typedoc/*"] -2021-08-12 09:29:51 INFO:  Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true} -2021-08-12 09:29:51 STATE: target: node type: tfjs: {"imports":1,"importBytes":102,"outputBytes":1303,"outputFiles":"dist/tfjs.esm.js"} -2021-08-12 09:29:51 STATE: target: node type: node: {"imports":42,"importBytes":436279,"outputBytes":377971,"outputFiles":"dist/human.node.js"} -2021-08-12 09:29:51 STATE: target: nodeGPU type: tfjs: {"imports":1,"importBytes":110,"outputBytes":1311,"outputFiles":"dist/tfjs.esm.js"} -2021-08-12 09:29:51 STATE: target: nodeGPU type: node: {"imports":42,"importBytes":436287,"outputBytes":377975,"outputFiles":"dist/human.node-gpu.js"} -2021-08-12 09:29:51 STATE: target: nodeWASM type: tfjs: {"imports":1,"importBytes":149,"outputBytes":1378,"outputFiles":"dist/tfjs.esm.js"} -2021-08-12 09:29:51 STATE: target: nodeWASM type: node: {"imports":42,"importBytes":436354,"outputBytes":378047,"outputFiles":"dist/human.node-wasm.js"} -2021-08-12 09:29:51 STATE: target: browserNoBundle type: tfjs: {"imports":1,"importBytes":2168,"outputBytes":1242,"outputFiles":"dist/tfjs.esm.js"} -2021-08-12 09:29:51 STATE: target: browserNoBundle type: esm: {"imports":42,"importBytes":436218,"outputBytes":248008,"outputFiles":"dist/human.esm-nobundle.js"} -2021-08-12 09:29:51 STATE: target: browserBundle type: tfjs: {"modules":1170,"moduleBytes":4145868,"imports":7,"importBytes":2168,"outputBytes":2334701,"outputFiles":"dist/tfjs.esm.js"} -2021-08-12 09:29:52 STATE: target: browserBundle type: iife: {"imports":42,"importBytes":2769677,"outputBytes":1378450,"outputFiles":"dist/human.js"} -2021-08-12 09:29:52 STATE: target: browserBundle type: esm: {"imports":42,"importBytes":2769677,"outputBytes":1378442,"outputFiles":"dist/human.esm.js"} -2021-08-12 09:29:52 INFO:  Running Linter: ["server/","src/","tfjs/","test/","demo/"] -2021-08-12 09:30:14 INFO:  Linter complete: files: 75 errors: 0 warnings: 0 -2021-08-12 09:30:14 INFO:  Generate ChangeLog: ["/home/vlado/dev/human/CHANGELOG.md"] -2021-08-12 09:30:14 INFO:  Generate Typings: ["src/human.ts"] outDir: ["types"] -2021-08-12 09:30:29 INFO:  Generate TypeDocs: ["src/human.ts"] outDir: ["typedoc"] -2021-08-12 09:30:43 INFO:  Documentation generated at /home/vlado/dev/human/typedoc 1 +2021-08-13 10:29:56 INFO:  @vladmandic/human version 2.1.3 +2021-08-13 10:29:56 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.5.0 +2021-08-13 10:29:56 INFO:  Toolchain: {"tfjs":"3.8.0","esbuild":"0.12.20","typescript":"4.3.5","typedoc":"0.21.5","eslint":"7.32.0"} +2021-08-13 10:29:56 INFO:  Clean: ["dist/*","types/*","typedoc/*"] +2021-08-13 10:29:56 INFO:  Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true} +2021-08-13 10:29:56 STATE: target: node type: tfjs: {"imports":1,"importBytes":102,"outputBytes":1303,"outputFiles":"dist/tfjs.esm.js"} +2021-08-13 10:29:56 STATE: target: node type: node: {"imports":42,"importBytes":436279,"outputBytes":377971,"outputFiles":"dist/human.node.js"} +2021-08-13 10:29:56 STATE: target: nodeGPU type: tfjs: {"imports":1,"importBytes":110,"outputBytes":1311,"outputFiles":"dist/tfjs.esm.js"} +2021-08-13 10:29:56 STATE: target: nodeGPU type: node: {"imports":42,"importBytes":436287,"outputBytes":377975,"outputFiles":"dist/human.node-gpu.js"} +2021-08-13 10:29:56 STATE: target: nodeWASM type: tfjs: {"imports":1,"importBytes":149,"outputBytes":1378,"outputFiles":"dist/tfjs.esm.js"} +2021-08-13 10:29:56 STATE: target: nodeWASM type: node: {"imports":42,"importBytes":436354,"outputBytes":378047,"outputFiles":"dist/human.node-wasm.js"} +2021-08-13 10:29:56 STATE: target: browserNoBundle type: tfjs: {"imports":1,"importBytes":2168,"outputBytes":1242,"outputFiles":"dist/tfjs.esm.js"} +2021-08-13 10:29:56 STATE: target: browserNoBundle type: esm: {"imports":42,"importBytes":436218,"outputBytes":248008,"outputFiles":"dist/human.esm-nobundle.js"} +2021-08-13 10:29:57 STATE: target: browserBundle type: tfjs: {"modules":1170,"moduleBytes":4145868,"imports":7,"importBytes":2168,"outputBytes":2334701,"outputFiles":"dist/tfjs.esm.js"} +2021-08-13 10:29:57 STATE: target: browserBundle type: iife: {"imports":42,"importBytes":2769677,"outputBytes":1378450,"outputFiles":"dist/human.js"} +2021-08-13 10:29:58 STATE: target: browserBundle type: esm: {"imports":42,"importBytes":2769677,"outputBytes":1378442,"outputFiles":"dist/human.esm.js"} +2021-08-13 10:29:58 INFO:  Running Linter: ["server/","src/","tfjs/","test/","demo/"] +2021-08-13 10:30:20 INFO:  Linter complete: files: 75 errors: 0 warnings: 0 +2021-08-13 10:30:21 INFO:  Generate ChangeLog: ["/home/vlado/dev/human/CHANGELOG.md"] +2021-08-13 10:30:21 INFO:  Generate Typings: ["src/human.ts"] outDir: ["types"] +2021-08-13 10:30:35 INFO:  Generate TypeDocs: ["src/human.ts"] outDir: ["typedoc"] +2021-08-13 10:30:49 INFO:  Documentation generated at /home/vlado/dev/human/typedoc 1