diff --git a/CHANGELOG.md b/CHANGELOG.md index 79879daf..b95b7449 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,9 @@ ## Changelog -### **HEAD -> main** 2022/09/21 mandic00@live.com +### **HEAD -> main** 2022/09/25 mandic00@live.com +- create funding.yml - fix rotation interpolation ### **2.10.3** 2022/09/21 mandic00@live.com diff --git a/README.md b/README.md index d98e8a2f..c0a849e7 100644 --- a/README.md +++ b/README.md @@ -170,9 +170,15 @@ and optionally matches detected face with database of known people to guess thei ![Face Matching](assets/screenshot-facematch.jpg) +2. **Face ID:** +Performs validation check on a webcam input to detect a real face and matches it to known faces stored in database +> [demo/faceid](demo/faceid/index.html) + +![Face Matching](assets/screenshot-faceid.jpg) +
-2. **3D Rendering:** +3. **3D Rendering:** > [human-motion](https://github.com/vladmandic/human-motion) ![Face3D](https://github.com/vladmandic/human-motion/raw/main/assets/screenshot-face.jpg) @@ -181,14 +187,14 @@ and optionally matches detected face with database of known people to guess thei
-3. **VR Model Tracking:** +4. **VR Model Tracking:** > [human-three-vrm](https://github.com/vladmandic/human-three-vrm) > [human-bjs-vrm](https://github.com/vladmandic/human-bjs-vrm) ![ThreeVRM](https://github.com/vladmandic/human-three-vrm/raw/main/assets/human-vrm-screenshot.jpg) -4. **Human as OS native application:** +5. **Human as OS native application:** > [human-electron](https://github.com/vladmandic/human-electron)
diff --git a/TODO.md b/TODO.md index bfca2f2e..f9f16337 100644 --- a/TODO.md +++ b/TODO.md @@ -50,5 +50,6 @@ Enable via `about:config` -> `gfx.offscreencanvas.enabled` - Enable model cache when using web workers - Fix for `face.rotation` interpolation - Improve NodeJS resolver when using ESM +- Update demo `demo/faceid` - Update demo `demo/nodejs/process-folder.js` and re-process `/samples` diff --git a/assets/screenshot-faceid.jpg b/assets/screenshot-faceid.jpg new file mode 100644 index 00000000..ed529ca3 Binary files /dev/null and b/assets/screenshot-faceid.jpg differ diff --git a/demo/faceid/index.html b/demo/faceid/index.html index d6a731a0..2e785444 100644 --- a/demo/faceid/index.html +++ b/demo/faceid/index.html @@ -19,14 +19,23 @@ body { margin: 0; padding: 16px; background: black; color: white; overflow-x: hidden; width: 100vw; height: 100vh; } body::-webkit-scrollbar { display: none; } .button { padding: 2px; cursor: pointer; box-shadow: 2px 2px black; width: 64px; text-align: center; place-content: center; margin-left: 16px; height: 16px; display: none } - .ok { position: absolute; top: 64px; right: 20px; width: 100px; background-color: grey; padding: 4px; color: black; font-size: 14px } + .ok { position: absolute; top: 64px; right: 20px; width: 150px; background-color: grey; padding: 4px; color: black; font-size: 14px } +
+

faceid demo using human library

+ look directly at camera and make sure that detection passes all of the required tests noted on the right hand side of the screen
+ if input does not satisfies tests within specific timeout, no image will be selected
+ once face image is approved, it will be compared with existing face database
+ you can also store face descriptor with label in a browser's indexdb for future usage
+
+ note: this is not equivalent to full faceid methods as used by modern mobile phones or windows hello
+ as they rely on additional infrared sensors and depth-sensing and not just camera image for additional levels of security
+
-

     

     
-    
retry
+
retry
diff --git a/demo/faceid/index.js b/demo/faceid/index.js index 35441db1..2cd259dd 100644 --- a/demo/faceid/index.js +++ b/demo/faceid/index.js @@ -4,6 +4,6 @@ author: ' */ -import*as I from"../../dist/human.esm.js";var l,z="human",g="person",p=(...t)=>console.log("indexdb",...t);async function v(){return l?!0:new Promise(t=>{let n=indexedDB.open(z,1);n.onerror=r=>p("error:",r),n.onupgradeneeded=r=>{p("create:",r.target),l=r.target.result,l.createObjectStore(g,{keyPath:"id",autoIncrement:!0})},n.onsuccess=r=>{l=r.target.result,p("open:",l),t(!0)}})}async function D(){let t=[];return l||await v(),new Promise(n=>{let r=l.transaction([g],"readwrite").objectStore(g).openCursor(null,"next");r.onerror=i=>p("load error:",i),r.onsuccess=i=>{i.target.result?(t.push(i.target.result.value),i.target.result.continue()):n(t)}})}async function y(){return l||await v(),new Promise(t=>{let n=l.transaction([g],"readwrite").objectStore(g).count();n.onerror=r=>p("count error:",r),n.onsuccess=()=>t(n.result)})}async function M(t){l||await v();let n={name:t.name,descriptor:t.descriptor,image:t.image};l.transaction([g],"readwrite").objectStore(g).put(n),p("save:",n)}async function B(t){l||await v(),l.transaction([g],"readwrite").objectStore(g).delete(t.id),p("delete:",t)}var b={modelBasePath:"../../models",filter:{equalization:!0},face:{enabled:!0,detector:{rotation:!0,return:!0,cropFactor:1.6,mask:!1},description:{enabled:!0},iris:{enabled:!0},emotion:{enabled:!1},antispoof:{enabled:!0},liveness:{enabled:!0}},body:{enabled:!1},hand:{enabled:!1},object:{enabled:!1},gesture:{enabled:!0}},S={order:2,multiplier:25,min:.2,max:.8},c={minConfidence:.6,minSize:224,maxTime:1e4,blinkMin:10,blinkMax:800,threshold:.5,mask:b.face.detector.mask,rotation:b.face.detector.rotation,cropFactor:b.face.detector.cropFactor,...S},o={faceCount:!1,faceConfidence:!1,facingCenter:!1,lookingCenter:!1,blinkDetected:!1,faceSize:!1,antispoofCheck:!1,livenessCheck:!1,elapsedMs:0},H=()=>o.faceCount&&o.faceSize&&o.blinkDetected&&o.facingCenter&&o.lookingCenter&&o.faceConfidence&&o.antispoofCheck&&o.livenessCheck,s={face:null,record:null},f={start:0,end:0,time:0},a=new I.Human(b);a.env.perfadd=!1;a.draw.options.font='small-caps 18px "Lato"';a.draw.options.lineHeight=20;var e={video:document.getElementById("video"),canvas:document.getElementById("canvas"),log:document.getElementById("log"),fps:document.getElementById("fps"),match:document.getElementById("match"),name:document.getElementById("name"),save:document.getElementById("save"),delete:document.getElementById("delete"),retry:document.getElementById("retry"),source:document.getElementById("source"),ok:document.getElementById("ok")},w={detect:0,draw:0},h={detect:0,draw:0},T=0,u=(...t)=>{e.log.innerText+=t.join(" ")+` -`,console.log(...t)},k=t=>e.fps.innerText=t;async function L(){k("starting webcam...");let t={audio:!1,video:{facingMode:"user",resizeMode:"none",width:{ideal:document.body.clientWidth}}},n=await navigator.mediaDevices.getUserMedia(t),r=new Promise(i=>{e.video.onloadeddata=()=>i(!0)});e.video.srcObject=n,e.video.play(),await r,e.canvas.width=e.video.videoWidth,e.canvas.height=e.video.videoHeight,a.env.initial&&u("video:",e.video.videoWidth,e.video.videoHeight,"|",n.getVideoTracks()[0].label),e.canvas.onclick=()=>{e.video.paused?e.video.play():e.video.pause()}}async function R(){var t;if(!e.video.paused){(t=s.face)!=null&&t.tensor&&a.tf.dispose(s.face.tensor),await a.detect(e.video);let n=a.now();h.detect=1e3/(n-w.detect),w.detect=n,requestAnimationFrame(R)}}async function F(){let t=a.next(a.result);a.draw.canvas(e.video,e.canvas),await a.draw.all(e.canvas,t);let n=a.now();if(h.draw=1e3/(n-w.draw),w.draw=n,k(`fps: ${h.detect.toFixed(1).padStart(5," ")} detect | ${h.draw.toFixed(1).padStart(5," ")} draw`),o.faceCount=a.result.face.length===1,o.faceCount){let i=Object.values(a.result.gesture).map(m=>m.gesture);(i.includes("blink left eye")||i.includes("blink right eye"))&&(f.start=a.now()),f.start>0&&!i.includes("blink left eye")&&!i.includes("blink right eye")&&(f.end=a.now()),o.blinkDetected=o.blinkDetected||Math.abs(f.end-f.start)>c.blinkMin&&Math.abs(f.end-f.start)c.minConfidence&&(a.result.face[0].faceScore||0)>c.minConfidence,o.antispoofCheck=(a.result.face[0].real||0)>c.minConfidence,o.livenessCheck=(a.result.face[0].live||0)>c.minConfidence,o.faceSize=a.result.face[0].box[2]>=c.minSize&&a.result.face[0].box[3]>=c.minSize}let r=32;for(let[i,m]of Object.entries(o)){let d=document.getElementById(`ok-${i}`);d||(d=document.createElement("div"),d.innerText=i,d.className="ok",d.style.top=`${r}px`,e.ok.appendChild(d)),typeof m=="boolean"?d.style.backgroundColor=m?"lightgreen":"lightcoral":d.innerText=`${i}:${m}`,r+=28}return H()||o.elapsedMs>c.maxTime?(e.video.pause(),a.result.face[0]):(o.elapsedMs=Math.trunc(a.now()-T),new Promise(i=>{setTimeout(async()=>{await F(),i(a.result.face[0])},30)}))}async function j(){var t,n,r,i;if(e.name.value.length>0){let m=(t=e.canvas.getContext("2d"))==null?void 0:t.getImageData(0,0,e.canvas.width,e.canvas.height),d={id:0,name:e.name.value,descriptor:(n=s.face)==null?void 0:n.embedding,image:m};await M(d),u("saved face record:",d.name,"descriptor length:",(i=(r=s.face)==null?void 0:r.embedding)==null?void 0:i.length),u("known face records:",await y())}else u("invalid name")}async function q(){s.record&&s.record.id>0&&await B(s.record)}async function O(){var i,m,d,C;if((i=e.canvas.getContext("2d"))==null||i.clearRect(0,0,c.minSize,c.minSize),!((m=s==null?void 0:s.face)!=null&&m.tensor)||!((d=s==null?void 0:s.face)!=null&&d.embedding))return!1;if(console.log("face record:",s.face),a.tf.browser.toPixels(s.face.tensor,e.canvas),await y()===0)return u("face database is empty"),document.body.style.background="black",e.delete.style.display="none",!1;let t=await D(),n=t.map(x=>x.descriptor).filter(x=>x.length>0),r=a.match(s.face.embedding,n,S);return s.record=t[r.index]||null,s.record&&(u(`best match: ${s.record.name} | id: ${s.record.id} | similarity: ${Math.round(1e3*r.similarity)/10}%`),e.name.value=s.record.name,e.source.style.display="",(C=e.source.getContext("2d"))==null||C.putImageData(s.record.image,0,0)),document.body.style.background=r.similarity>c.threshold?"darkgreen":"maroon",r.similarity>c.threshold}async function E(){var t,n;return o.faceCount=!1,o.faceConfidence=!1,o.facingCenter=!1,o.blinkDetected=!1,o.faceSize=!1,o.antispoofCheck=!1,o.livenessCheck=!1,o.elapsedMs=0,e.match.style.display="none",e.retry.style.display="none",e.source.style.display="none",document.body.style.background="black",await L(),await R(),T=a.now(),s.face=await F(),e.canvas.width=((t=s.face.tensor)==null?void 0:t.shape[1])||c.minSize,e.canvas.height=((n=s.face.tensor)==null?void 0:n.shape[0])||c.minSize,e.source.width=e.canvas.width,e.source.height=e.canvas.height,e.canvas.style.width="",e.match.style.display="flex",e.save.style.display="flex",e.delete.style.display="flex",e.retry.style.display="block",H()?O():(u("did not find valid face"),!1)}async function $(){var t,n;u("human version:",a.version,"| tfjs version:",a.tf.version["tfjs-core"]),u("face embedding model:",b.face.description.enabled?"faceres":"",(t=b.face.mobilefacenet)!=null&&t.enabled?"mobilefacenet":"",(n=b.face.insightface)!=null&&n.enabled?"insightface":""),u("options:",JSON.stringify(c).replace(/{|}|"|\[|\]/g,"").replace(/,/g," ")),k("loading..."),u("known face records:",await y()),await L(),await a.load(),k("initializing..."),e.retry.addEventListener("click",E),e.save.addEventListener("click",j),e.delete.addEventListener("click",q),await a.warmup(),await E()}window.onload=$; +import*as S from"../../dist/human.esm.js";var l,L="human",f="person",v=(...a)=>console.log("indexdb",...a);async function h(){return l?!0:new Promise(a=>{let n=indexedDB.open(L,1);n.onerror=o=>v("error:",o),n.onupgradeneeded=o=>{v("create:",o.target),l=o.target.result,l.createObjectStore(f,{keyPath:"id",autoIncrement:!0})},n.onsuccess=o=>{l=o.target.result,v("open:",l),a(!0)}})}async function C(){let a=[];return l||await h(),new Promise(n=>{let o=l.transaction([f],"readwrite").objectStore(f).openCursor(null,"next");o.onerror=i=>v("load error:",i),o.onsuccess=i=>{i.target.result?(a.push(i.target.result.value),i.target.result.continue()):n(a)}})}async function b(){return l||await h(),new Promise(a=>{let n=l.transaction([f],"readwrite").objectStore(f).count();n.onerror=o=>v("count error:",o),n.onsuccess=()=>a(n.result)})}async function x(a){l||await h();let n={name:a.name,descriptor:a.descriptor,image:a.image};l.transaction([f],"readwrite").objectStore(f).put(n),v("save:",n)}async function D(a){l||await h(),l.transaction([f],"readwrite").objectStore(f).delete(a.id),v("delete:",a)}var g={cacheSensitivity:0,modelBasePath:"../../models",filter:{equalization:!0},face:{enabled:!0,detector:{rotation:!0,return:!0,cropFactor:1.6,mask:!1},description:{enabled:!0},iris:{enabled:!0},emotion:{enabled:!1},antispoof:{enabled:!0},liveness:{enabled:!0}},body:{enabled:!1},hand:{enabled:!1},object:{enabled:!1},gesture:{enabled:!0}},B={order:2,multiplier:25,min:.2,max:.8},d={minConfidence:.6,minSize:224,maxTime:3e4,blinkMin:10,blinkMax:800,threshold:.5,mask:g.face.detector.mask,rotation:g.face.detector.rotation,cropFactor:g.face.detector.cropFactor,...B},e={faceCount:{status:!1,val:0},faceConfidence:{status:!1,val:0},facingCenter:{status:!1,val:0},lookingCenter:{status:!1,val:0},blinkDetected:{status:!1,val:0},faceSize:{status:!1,val:0},antispoofCheck:{status:!1,val:0},livenessCheck:{status:!1,val:0},age:{status:!1,val:0},gender:{status:!1,val:0},timeout:{status:!0,val:0},descriptor:{status:!1,val:0},elapsedMs:{status:void 0,val:0},detectFPS:{status:void 0,val:0},drawFPS:{status:void 0,val:0}},E=()=>e.faceCount.status&&e.faceSize.status&&e.blinkDetected.status&&e.facingCenter.status&&e.lookingCenter.status&&e.faceConfidence.status&&e.antispoofCheck.status&&e.livenessCheck.status&&e.descriptor.status&&e.age.status&&e.gender.status,c={face:null,record:null},u={start:0,end:0,time:0},s=new S.Human(g);s.env.perfadd=!1;s.draw.options.font='small-caps 18px "Lato"';s.draw.options.lineHeight=20;var t={video:document.getElementById("video"),canvas:document.getElementById("canvas"),log:document.getElementById("log"),fps:document.getElementById("fps"),match:document.getElementById("match"),name:document.getElementById("name"),save:document.getElementById("save"),delete:document.getElementById("delete"),retry:document.getElementById("retry"),source:document.getElementById("source"),ok:document.getElementById("ok")},y={detect:0,draw:0},I=0,r=(...a)=>{t.log.innerText+=a.join(" ")+` +`,console.log(...a)};async function H(){let a={audio:!1,video:{facingMode:"user",resizeMode:"none",width:{ideal:document.body.clientWidth}}},n=await navigator.mediaDevices.getUserMedia(a),o=new Promise(i=>{t.video.onloadeddata=()=>i(!0)});t.video.srcObject=n,t.video.play(),await o,t.canvas.width=t.video.videoWidth,t.canvas.height=t.video.videoHeight,t.canvas.style.width="50%",t.canvas.style.height="50%",s.env.initial&&r("video:",t.video.videoWidth,t.video.videoHeight,"|",n.getVideoTracks()[0].label),t.canvas.onclick=()=>{t.video.paused?t.video.play():t.video.pause()}}async function T(){var a;if(!t.video.paused){(a=c.face)!=null&&a.tensor&&s.tf.dispose(c.face.tensor),await s.detect(t.video);let n=s.now();e.detectFPS.val=Math.round(1e4/(n-y.detect))/10,y.detect=n,requestAnimationFrame(T)}}function P(){let a=32;for(let[n,o]of Object.entries(e)){let i=document.getElementById(`ok-${n}`);i||(i=document.createElement("div"),i.id=`ok-${n}`,i.innerText=n,i.className="ok",i.style.top=`${a}px`,t.ok.appendChild(i)),typeof o.status=="boolean"&&(i.style.backgroundColor=o.status?"lightgreen":"lightcoral");let m=o.status?"ok":"fail";i.innerText=`${n}: ${o.val===0?m:o.val}`,a+=28}}async function R(){var o;let a=s.next(s.result);s.draw.canvas(t.video,t.canvas),await s.draw.all(t.canvas,a);let n=s.now();if(e.drawFPS.val=Math.round(1e4/(n-y.draw))/10,y.draw=n,e.faceCount.val=s.result.face.length,e.faceCount.status=e.faceCount.val===1,e.faceCount.status){let i=Object.values(s.result.gesture).map(m=>m.gesture);(i.includes("blink left eye")||i.includes("blink right eye"))&&(u.start=s.now()),u.start>0&&!i.includes("blink left eye")&&!i.includes("blink right eye")&&(u.end=s.now()),e.blinkDetected.status=e.blinkDetected.status||Math.abs(u.end-u.start)>d.blinkMin&&Math.abs(u.end-u.start)=d.minConfidence,e.antispoofCheck.val=s.result.face[0].real||0,e.antispoofCheck.status=e.antispoofCheck.val>=d.minConfidence,e.livenessCheck.val=s.result.face[0].live||0,e.livenessCheck.status=e.livenessCheck.val>=d.minConfidence,e.faceSize.val=Math.min(s.result.face[0].box[2],s.result.face[0].box[3]),e.faceSize.status=e.faceSize.val>=d.minSize,e.descriptor.val=((o=s.result.face[0].embedding)==null?void 0:o.length)||0,e.descriptor.status=e.descriptor.val>0,e.age.val=s.result.face[0].age||0,e.age.status=e.age.val>0,e.gender.val=s.result.face[0].genderScore||0,e.gender.status=e.gender.val>=d.minConfidence}return e.timeout.status=e.elapsedMs.val<=d.maxTime,P(),E()||!e.timeout.status?(t.video.pause(),s.result.face[0]):(e.elapsedMs.val=Math.trunc(s.now()-I),new Promise(i=>{setTimeout(async()=>{await R(),i(s.result.face[0])},30)}))}async function z(){var a,n,o,i;if(t.name.value.length>0){let m=(a=t.canvas.getContext("2d"))==null?void 0:a.getImageData(0,0,t.canvas.width,t.canvas.height),p={id:0,name:t.name.value,descriptor:(n=c.face)==null?void 0:n.embedding,image:m};await x(p),r("saved face record:",p.name,"descriptor length:",(i=(o=c.face)==null?void 0:o.embedding)==null?void 0:i.length),r("known face records:",await b())}else r("invalid name")}async function j(){c.record&&c.record.id>0&&await D(c.record)}async function $(){var i,m,p,k;if(t.canvas.style.height="",(i=t.canvas.getContext("2d"))==null||i.clearRect(0,0,d.minSize,d.minSize),!((m=c==null?void 0:c.face)!=null&&m.tensor)||!((p=c==null?void 0:c.face)!=null&&p.embedding))return!1;if(console.log("face record:",c.face),r(`detected face: ${c.face.gender} ${c.face.age||0}y distance ${c.face.iris||0}cm/${Math.round(100*(c.face.iris||0)/2.54)/100}in`),s.tf.browser.toPixels(c.face.tensor,t.canvas),await b()===0)return r("face database is empty: nothing to compare face with"),document.body.style.background="black",t.delete.style.display="none",!1;let a=await C(),n=a.map(w=>w.descriptor).filter(w=>w.length>0),o=s.match(c.face.embedding,n,B);return c.record=a[o.index]||null,c.record&&(r(`best match: ${c.record.name} | id: ${c.record.id} | similarity: ${Math.round(1e3*o.similarity)/10}%`),t.name.value=c.record.name,t.source.style.display="",(k=t.source.getContext("2d"))==null||k.putImageData(c.record.image,0,0)),document.body.style.background=o.similarity>d.threshold?"darkgreen":"maroon",o.similarity>d.threshold}async function M(){var a,n;return e.faceCount.status=!1,e.faceConfidence.status=!1,e.facingCenter.status=!1,e.blinkDetected.status=!1,e.faceSize.status=!1,e.antispoofCheck.status=!1,e.livenessCheck.status=!1,e.age.status=!1,e.gender.status=!1,e.elapsedMs.val=0,t.match.style.display="none",t.retry.style.display="none",t.source.style.display="none",t.canvas.style.height="50%",document.body.style.background="black",await H(),await T(),I=s.now(),c.face=await R(),t.canvas.width=((a=c.face.tensor)==null?void 0:a.shape[1])||d.minSize,t.canvas.height=((n=c.face.tensor)==null?void 0:n.shape[0])||d.minSize,t.source.width=t.canvas.width,t.source.height=t.canvas.height,t.canvas.style.width="",t.match.style.display="flex",t.save.style.display="flex",t.delete.style.display="flex",t.retry.style.display="block",E()?$():(r("did not find valid face"),!1)}async function q(){var a,n;r("human version:",s.version,"| tfjs version:",s.tf.version["tfjs-core"]),r("options:",JSON.stringify(d).replace(/{|}|"|\[|\]/g,"").replace(/,/g," ")),r("initializing webcam..."),await H(),r("loading human models..."),await s.load(),r("initializing human..."),r("face embedding model:",g.face.description.enabled?"faceres":"",(a=g.face.mobilefacenet)!=null&&a.enabled?"mobilefacenet":"",(n=g.face.insightface)!=null&&n.enabled?"insightface":""),r("loading face database..."),r("known face records:",await b()),t.retry.addEventListener("click",M),t.save.addEventListener("click",z),t.delete.addEventListener("click",j),await s.warmup(),await M()}window.onload=q; //# sourceMappingURL=index.js.map diff --git a/demo/faceid/index.js.map b/demo/faceid/index.js.map index d9e1c020..ba7ac80d 100644 --- a/demo/faceid/index.js.map +++ b/demo/faceid/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["index.ts", "indexdb.ts"], - "sourcesContent": ["/**\n * Human demo for browsers\n * @default Human Library\n * @summary \n * @author \n * @copyright \n * @license MIT\n */\n\nimport * as H from '../../dist/human.esm.js'; // equivalent of @vladmandic/Human\nimport * as indexDb from './indexdb'; // methods to deal with indexdb\n\nconst humanConfig = { // user configuration for human, used to fine-tune behavior\n modelBasePath: '../../models',\n filter: { equalization: true }, // lets run with histogram equilizer\n face: {\n enabled: true,\n detector: { rotation: true, return: true, cropFactor: 1.6, mask: false }, // return tensor is used to get detected face image\n description: { enabled: true }, // default model for face descriptor extraction is faceres\n // mobilefacenet: { enabled: true, modelPath: 'https://vladmandic.github.io/human-models/models/mobilefacenet.json' }, // alternative model\n // insightface: { enabled: true, modelPath: 'https://vladmandic.github.io/insightface/models/insightface-mobilenet-swish.json' }, // alternative model\n iris: { enabled: true }, // needed to determine gaze direction\n emotion: { enabled: false }, // not needed\n antispoof: { enabled: true }, // enable optional antispoof module\n liveness: { enabled: true }, // enable optional liveness module\n },\n body: { enabled: false },\n hand: { enabled: false },\n object: { enabled: false },\n gesture: { enabled: true }, // parses face and iris gestures\n};\n\n// const matchOptions = { order: 2, multiplier: 1000, min: 0.0, max: 1.0 }; // for embedding model\nconst matchOptions = { order: 2, multiplier: 25, min: 0.2, max: 0.8 }; // for faceres model\n\nconst options = {\n minConfidence: 0.6, // overal face confidence for box, face, gender, real, live\n minSize: 224, // min input to face descriptor model before degradation\n maxTime: 10000, // max time before giving up\n blinkMin: 10, // minimum duration of a valid blink\n blinkMax: 800, // maximum duration of a valid blink\n threshold: 0.5, // minimum similarity\n mask: humanConfig.face.detector.mask,\n rotation: humanConfig.face.detector.rotation,\n cropFactor: humanConfig.face.detector.cropFactor,\n ...matchOptions,\n};\n\nconst ok = { // must meet all rules\n faceCount: false,\n faceConfidence: false,\n facingCenter: false,\n lookingCenter: false,\n blinkDetected: false,\n faceSize: false,\n antispoofCheck: false,\n livenessCheck: false,\n elapsedMs: 0, // total time while waiting for valid face\n};\nconst allOk = () => ok.faceCount && ok.faceSize && ok.blinkDetected && ok.facingCenter && ok.lookingCenter && ok.faceConfidence && ok.antispoofCheck && ok.livenessCheck;\nconst current: { face: H.FaceResult | null, record: indexDb.FaceRecord | null } = { face: null, record: null }; // current face record and matched database record\n\nconst blink = { // internal timers for blink start/end/duration\n start: 0,\n end: 0,\n time: 0,\n};\n\n// let db: Array<{ name: string, source: string, embedding: number[] }> = []; // holds loaded face descriptor database\nconst human = new H.Human(humanConfig); // create instance of human with overrides from user configuration\n\nhuman.env.perfadd = false; // is performance data showing instant or total values\nhuman.draw.options.font = 'small-caps 18px \"Lato\"'; // set font used to draw labels when using draw methods\nhuman.draw.options.lineHeight = 20;\n\nconst dom = { // grab instances of dom objects so we dont have to look them up later\n video: document.getElementById('video') as HTMLVideoElement,\n canvas: document.getElementById('canvas') as HTMLCanvasElement,\n log: document.getElementById('log') as HTMLPreElement,\n fps: document.getElementById('fps') as HTMLPreElement,\n match: document.getElementById('match') as HTMLDivElement,\n name: document.getElementById('name') as HTMLInputElement,\n save: document.getElementById('save') as HTMLSpanElement,\n delete: document.getElementById('delete') as HTMLSpanElement,\n retry: document.getElementById('retry') as HTMLDivElement,\n source: document.getElementById('source') as HTMLCanvasElement,\n ok: document.getElementById('ok') as HTMLDivElement,\n};\nconst timestamp = { detect: 0, draw: 0 }; // holds information used to calculate performance and possible memory leaks\nconst fps = { detect: 0, draw: 0 }; // holds calculated fps information for both detect and screen refresh\nlet startTime = 0;\n\nconst log = (...msg) => { // helper method to output messages\n dom.log.innerText += msg.join(' ') + '\\n';\n console.log(...msg); // eslint-disable-line no-console\n};\nconst printFPS = (msg) => dom.fps.innerText = msg; // print status element\n\nasync function webCam() { // initialize webcam\n printFPS('starting webcam...');\n // @ts-ignore resizeMode is not yet defined in tslib\n const cameraOptions: MediaStreamConstraints = { audio: false, video: { facingMode: 'user', resizeMode: 'none', width: { ideal: document.body.clientWidth } } };\n const stream: MediaStream = await navigator.mediaDevices.getUserMedia(cameraOptions);\n const ready = new Promise((resolve) => { dom.video.onloadeddata = () => resolve(true); });\n dom.video.srcObject = stream;\n void dom.video.play();\n await ready;\n dom.canvas.width = dom.video.videoWidth;\n dom.canvas.height = dom.video.videoHeight;\n if (human.env.initial) log('video:', dom.video.videoWidth, dom.video.videoHeight, '|', stream.getVideoTracks()[0].label);\n dom.canvas.onclick = () => { // pause when clicked on screen and resume on next click\n if (dom.video.paused) void dom.video.play();\n else dom.video.pause();\n };\n}\n\nasync function detectionLoop() { // main detection loop\n if (!dom.video.paused) {\n if (current.face?.tensor) human.tf.dispose(current.face.tensor); // dispose previous tensor\n await human.detect(dom.video); // actual detection; were not capturing output in a local variable as it can also be reached via human.result\n const now = human.now();\n fps.detect = 1000 / (now - timestamp.detect);\n timestamp.detect = now;\n requestAnimationFrame(detectionLoop); // start new frame immediately\n }\n}\n\nasync function validationLoop(): Promise { // main screen refresh loop\n const interpolated = human.next(human.result); // smoothen result using last-known results\n human.draw.canvas(dom.video, dom.canvas); // draw canvas to screen\n await human.draw.all(dom.canvas, interpolated); // draw labels, boxes, lines, etc.\n const now = human.now();\n fps.draw = 1000 / (now - timestamp.draw);\n timestamp.draw = now;\n printFPS(`fps: ${fps.detect.toFixed(1).padStart(5, ' ')} detect | ${fps.draw.toFixed(1).padStart(5, ' ')} draw`); // write status\n ok.faceCount = human.result.face.length === 1; // must be exactly detected face\n if (ok.faceCount) { // skip the rest if no face\n const gestures: string[] = Object.values(human.result.gesture).map((gesture: H.GestureResult) => gesture.gesture); // flatten all gestures\n if (gestures.includes('blink left eye') || gestures.includes('blink right eye')) blink.start = human.now(); // blink starts when eyes get closed\n if (blink.start > 0 && !gestures.includes('blink left eye') && !gestures.includes('blink right eye')) blink.end = human.now(); // if blink started how long until eyes are back open\n ok.blinkDetected = ok.blinkDetected || (Math.abs(blink.end - blink.start) > options.blinkMin && Math.abs(blink.end - blink.start) < options.blinkMax);\n if (ok.blinkDetected && blink.time === 0) blink.time = Math.trunc(blink.end - blink.start);\n ok.facingCenter = gestures.includes('facing center');\n ok.lookingCenter = gestures.includes('looking center'); // must face camera and look at camera\n ok.faceConfidence = (human.result.face[0].boxScore || 0) > options.minConfidence && (human.result.face[0].faceScore || 0) > options.minConfidence;\n ok.antispoofCheck = (human.result.face[0].real || 0) > options.minConfidence;\n ok.livenessCheck = (human.result.face[0].live || 0) > options.minConfidence;\n ok.faceSize = human.result.face[0].box[2] >= options.minSize && human.result.face[0].box[3] >= options.minSize;\n }\n let y = 32;\n for (const [key, val] of Object.entries(ok)) {\n let el = document.getElementById(`ok-${key}`);\n if (!el) {\n el = document.createElement('div');\n el.innerText = key;\n el.className = 'ok';\n el.style.top = `${y}px`;\n dom.ok.appendChild(el);\n }\n if (typeof val === 'boolean') el.style.backgroundColor = val ? 'lightgreen' : 'lightcoral';\n else el.innerText = `${key}:${val}`;\n y += 28;\n }\n if (allOk()) { // all criteria met\n dom.video.pause();\n return human.result.face[0];\n }\n if (ok.elapsedMs > options.maxTime) { // give up\n dom.video.pause();\n return human.result.face[0];\n }\n // run again\n ok.elapsedMs = Math.trunc(human.now() - startTime);\n return new Promise((resolve) => {\n setTimeout(async () => {\n await validationLoop(); // run validation loop until conditions are met\n resolve(human.result.face[0]); // recursive promise resolve\n }, 30); // use to slow down refresh from max refresh rate to target of 30 fps\n });\n}\n\nasync function saveRecords() {\n if (dom.name.value.length > 0) {\n const image = dom.canvas.getContext('2d')?.getImageData(0, 0, dom.canvas.width, dom.canvas.height) as ImageData;\n const rec = { id: 0, name: dom.name.value, descriptor: current.face?.embedding as number[], image };\n await indexDb.save(rec);\n log('saved face record:', rec.name, 'descriptor length:', current.face?.embedding?.length);\n log('known face records:', await indexDb.count());\n } else {\n log('invalid name');\n }\n}\n\nasync function deleteRecord() {\n if (current.record && current.record.id > 0) {\n await indexDb.remove(current.record);\n }\n}\n\nasync function detectFace() {\n dom.canvas.getContext('2d')?.clearRect(0, 0, options.minSize, options.minSize);\n if (!current?.face?.tensor || !current?.face?.embedding) return false;\n console.log('face record:', current.face); // eslint-disable-line no-console\n human.tf.browser.toPixels(current.face.tensor as unknown as H.TensorLike, dom.canvas);\n if (await indexDb.count() === 0) {\n log('face database is empty');\n document.body.style.background = 'black';\n dom.delete.style.display = 'none';\n return false;\n }\n const db = await indexDb.load();\n const descriptors = db.map((rec) => rec.descriptor).filter((desc) => desc.length > 0);\n const res = human.match(current.face.embedding, descriptors, matchOptions);\n current.record = db[res.index] || null;\n if (current.record) {\n log(`best match: ${current.record.name} | id: ${current.record.id} | similarity: ${Math.round(1000 * res.similarity) / 10}%`);\n dom.name.value = current.record.name;\n dom.source.style.display = '';\n dom.source.getContext('2d')?.putImageData(current.record.image, 0, 0);\n }\n document.body.style.background = res.similarity > options.threshold ? 'darkgreen' : 'maroon';\n return res.similarity > options.threshold;\n}\n\nasync function main() { // main entry point\n ok.faceCount = false;\n ok.faceConfidence = false;\n ok.facingCenter = false;\n ok.blinkDetected = false;\n ok.faceSize = false;\n ok.antispoofCheck = false;\n ok.livenessCheck = false;\n ok.elapsedMs = 0;\n dom.match.style.display = 'none';\n dom.retry.style.display = 'none';\n dom.source.style.display = 'none';\n document.body.style.background = 'black';\n await webCam();\n await detectionLoop(); // start detection loop\n startTime = human.now();\n current.face = await validationLoop(); // start validation loop\n dom.canvas.width = current.face.tensor?.shape[1] || options.minSize;\n dom.canvas.height = current.face.tensor?.shape[0] || options.minSize;\n dom.source.width = dom.canvas.width;\n dom.source.height = dom.canvas.height;\n dom.canvas.style.width = '';\n dom.match.style.display = 'flex';\n dom.save.style.display = 'flex';\n dom.delete.style.display = 'flex';\n dom.retry.style.display = 'block';\n if (!allOk()) { // is all criteria met?\n log('did not find valid face');\n return false;\n }\n return detectFace();\n}\n\nasync function init() {\n log('human version:', human.version, '| tfjs version:', human.tf.version['tfjs-core']);\n log('face embedding model:', humanConfig.face.description.enabled ? 'faceres' : '', humanConfig.face['mobilefacenet']?.enabled ? 'mobilefacenet' : '', humanConfig.face['insightface']?.enabled ? 'insightface' : '');\n log('options:', JSON.stringify(options).replace(/{|}|\"|\\[|\\]/g, '').replace(/,/g, ' '));\n printFPS('loading...');\n log('known face records:', await indexDb.count());\n await webCam(); // start webcam\n await human.load(); // preload all models\n printFPS('initializing...');\n dom.retry.addEventListener('click', main);\n dom.save.addEventListener('click', saveRecords);\n dom.delete.addEventListener('click', deleteRecord);\n await human.warmup(); // warmup function to initialize backend for future faster detection\n await main();\n}\n\nwindow.onload = init;\n", "let db: IDBDatabase; // instance of indexdb\n\nconst database = 'human';\nconst table = 'person';\n\nexport interface FaceRecord { id: number, name: string, descriptor: number[], image: ImageData }\n\nconst log = (...msg) => console.log('indexdb', ...msg); // eslint-disable-line no-console\n\nexport async function open() {\n if (db) return true;\n return new Promise((resolve) => {\n const request: IDBOpenDBRequest = indexedDB.open(database, 1);\n request.onerror = (evt) => log('error:', evt);\n request.onupgradeneeded = (evt: IDBVersionChangeEvent) => { // create if doesnt exist\n log('create:', evt.target);\n db = (evt.target as IDBOpenDBRequest).result;\n db.createObjectStore(table, { keyPath: 'id', autoIncrement: true });\n };\n request.onsuccess = (evt) => { // open\n db = (evt.target as IDBOpenDBRequest).result;\n log('open:', db);\n resolve(true);\n };\n });\n}\n\nexport async function load(): Promise {\n const faceDB: FaceRecord[] = [];\n if (!db) await open(); // open or create if not already done\n return new Promise((resolve) => {\n const cursor: IDBRequest = db.transaction([table], 'readwrite').objectStore(table).openCursor(null, 'next');\n cursor.onerror = (evt) => log('load error:', evt);\n cursor.onsuccess = (evt) => {\n if ((evt.target as IDBRequest).result) {\n faceDB.push((evt.target as IDBRequest).result.value);\n (evt.target as IDBRequest).result.continue();\n } else {\n resolve(faceDB);\n }\n };\n });\n}\n\nexport async function count(): Promise {\n if (!db) await open(); // open or create if not already done\n return new Promise((resolve) => {\n const store: IDBRequest = db.transaction([table], 'readwrite').objectStore(table).count();\n store.onerror = (evt) => log('count error:', evt);\n store.onsuccess = () => resolve(store.result);\n });\n}\n\nexport async function save(faceRecord: FaceRecord) {\n if (!db) await open(); // open or create if not already done\n const newRecord = { name: faceRecord.name, descriptor: faceRecord.descriptor, image: faceRecord.image }; // omit id as its autoincrement\n db.transaction([table], 'readwrite').objectStore(table).put(newRecord);\n log('save:', newRecord);\n}\n\nexport async function remove(faceRecord: FaceRecord) {\n if (!db) await open(); // open or create if not already done\n db.transaction([table], 'readwrite').objectStore(table).delete(faceRecord.id); // delete based on id\n log('delete:', faceRecord);\n}\n"], - "mappings": ";;;;;;AASA,UAAYA,MAAO,0BCTnB,IAAIC,EAEEC,EAAW,QACXC,EAAQ,SAIRC,EAAM,IAAIC,IAAQ,QAAQ,IAAI,UAAW,GAAGA,CAAG,EAErD,eAAsBC,GAAO,CAC3B,OAAIL,EAAW,GACR,IAAI,QAASM,GAAY,CAC9B,IAAMC,EAA4B,UAAU,KAAKN,EAAU,CAAC,EAC5DM,EAAQ,QAAWC,GAAQL,EAAI,SAAUK,CAAG,EAC5CD,EAAQ,gBAAmBC,GAA+B,CACxDL,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names": ["H", "db", "database", "table", "log", "msg", "open", "resolve", "request", "evt", "load", "faceDB", "cursor", "count", "store", "save", "faceRecord", "newRecord", "remove", "humanConfig", "matchOptions", "options", "ok", "allOk", "current", "blink", "human", "dom", "timestamp", "fps", "startTime", "log", "msg", "printFPS", "webCam", "cameraOptions", "stream", "ready", "resolve", "detectionLoop", "_a", "now", "validationLoop", "interpolated", "gestures", "gesture", "y", "key", "val", "el", "saveRecords", "_b", "_c", "_d", "image", "rec", "save", "count", "deleteRecord", "remove", "detectFace", "db", "load", "descriptors", "desc", "res", "main", "init"] + "sourcesContent": ["/**\n * Human demo for browsers\n * @default Human Library\n * @summary \n * @author \n * @copyright \n * @license MIT\n */\n\nimport * as H from '../../dist/human.esm.js'; // equivalent of @vladmandic/Human\nimport * as indexDb from './indexdb'; // methods to deal with indexdb\n\nconst humanConfig = { // user configuration for human, used to fine-tune behavior\n cacheSensitivity: 0,\n modelBasePath: '../../models',\n filter: { equalization: true }, // lets run with histogram equilizer\n face: {\n enabled: true,\n detector: { rotation: true, return: true, cropFactor: 1.6, mask: false }, // return tensor is used to get detected face image\n description: { enabled: true }, // default model for face descriptor extraction is faceres\n // mobilefacenet: { enabled: true, modelPath: 'https://vladmandic.github.io/human-models/models/mobilefacenet.json' }, // alternative model\n // insightface: { enabled: true, modelPath: 'https://vladmandic.github.io/insightface/models/insightface-mobilenet-swish.json' }, // alternative model\n iris: { enabled: true }, // needed to determine gaze direction\n emotion: { enabled: false }, // not needed\n antispoof: { enabled: true }, // enable optional antispoof module\n liveness: { enabled: true }, // enable optional liveness module\n },\n body: { enabled: false },\n hand: { enabled: false },\n object: { enabled: false },\n gesture: { enabled: true }, // parses face and iris gestures\n};\n\n// const matchOptions = { order: 2, multiplier: 1000, min: 0.0, max: 1.0 }; // for embedding model\nconst matchOptions = { order: 2, multiplier: 25, min: 0.2, max: 0.8 }; // for faceres model\n\nconst options = {\n minConfidence: 0.6, // overal face confidence for box, face, gender, real, live\n minSize: 224, // min input to face descriptor model before degradation\n maxTime: 30000, // max time before giving up\n blinkMin: 10, // minimum duration of a valid blink\n blinkMax: 800, // maximum duration of a valid blink\n threshold: 0.5, // minimum similarity\n mask: humanConfig.face.detector.mask,\n rotation: humanConfig.face.detector.rotation,\n cropFactor: humanConfig.face.detector.cropFactor,\n ...matchOptions,\n};\n\nconst ok: Record = { // must meet all rules\n faceCount: { status: false, val: 0 },\n faceConfidence: { status: false, val: 0 },\n facingCenter: { status: false, val: 0 },\n lookingCenter: { status: false, val: 0 },\n blinkDetected: { status: false, val: 0 },\n faceSize: { status: false, val: 0 },\n antispoofCheck: { status: false, val: 0 },\n livenessCheck: { status: false, val: 0 },\n age: { status: false, val: 0 },\n gender: { status: false, val: 0 },\n timeout: { status: true, val: 0 },\n descriptor: { status: false, val: 0 },\n elapsedMs: { status: undefined, val: 0 }, // total time while waiting for valid face\n detectFPS: { status: undefined, val: 0 }, // mark detection fps performance\n drawFPS: { status: undefined, val: 0 }, // mark redraw fps performance\n};\n\nconst allOk = () => ok.faceCount.status\n && ok.faceSize.status\n && ok.blinkDetected.status\n && ok.facingCenter.status\n && ok.lookingCenter.status\n && ok.faceConfidence.status\n && ok.antispoofCheck.status\n && ok.livenessCheck.status\n && ok.descriptor.status\n && ok.age.status\n && ok.gender.status;\n\nconst current: { face: H.FaceResult | null, record: indexDb.FaceRecord | null } = { face: null, record: null }; // current face record and matched database record\n\nconst blink = { // internal timers for blink start/end/duration\n start: 0,\n end: 0,\n time: 0,\n};\n\n// let db: Array<{ name: string, source: string, embedding: number[] }> = []; // holds loaded face descriptor database\nconst human = new H.Human(humanConfig); // create instance of human with overrides from user configuration\n\nhuman.env.perfadd = false; // is performance data showing instant or total values\nhuman.draw.options.font = 'small-caps 18px \"Lato\"'; // set font used to draw labels when using draw methods\nhuman.draw.options.lineHeight = 20;\n\nconst dom = { // grab instances of dom objects so we dont have to look them up later\n video: document.getElementById('video') as HTMLVideoElement,\n canvas: document.getElementById('canvas') as HTMLCanvasElement,\n log: document.getElementById('log') as HTMLPreElement,\n fps: document.getElementById('fps') as HTMLPreElement,\n match: document.getElementById('match') as HTMLDivElement,\n name: document.getElementById('name') as HTMLInputElement,\n save: document.getElementById('save') as HTMLSpanElement,\n delete: document.getElementById('delete') as HTMLSpanElement,\n retry: document.getElementById('retry') as HTMLDivElement,\n source: document.getElementById('source') as HTMLCanvasElement,\n ok: document.getElementById('ok') as HTMLDivElement,\n};\nconst timestamp = { detect: 0, draw: 0 }; // holds information used to calculate performance and possible memory leaks\nlet startTime = 0;\n\nconst log = (...msg) => { // helper method to output messages\n dom.log.innerText += msg.join(' ') + '\\n';\n console.log(...msg); // eslint-disable-line no-console\n};\n\nasync function webCam() { // initialize webcam\n // @ts-ignore resizeMode is not yet defined in tslib\n const cameraOptions: MediaStreamConstraints = { audio: false, video: { facingMode: 'user', resizeMode: 'none', width: { ideal: document.body.clientWidth } } };\n const stream: MediaStream = await navigator.mediaDevices.getUserMedia(cameraOptions);\n const ready = new Promise((resolve) => { dom.video.onloadeddata = () => resolve(true); });\n dom.video.srcObject = stream;\n void dom.video.play();\n await ready;\n dom.canvas.width = dom.video.videoWidth;\n dom.canvas.height = dom.video.videoHeight;\n dom.canvas.style.width = '50%';\n dom.canvas.style.height = '50%';\n if (human.env.initial) log('video:', dom.video.videoWidth, dom.video.videoHeight, '|', stream.getVideoTracks()[0].label);\n dom.canvas.onclick = () => { // pause when clicked on screen and resume on next click\n if (dom.video.paused) void dom.video.play();\n else dom.video.pause();\n };\n}\n\nasync function detectionLoop() { // main detection loop\n if (!dom.video.paused) {\n if (current.face?.tensor) human.tf.dispose(current.face.tensor); // dispose previous tensor\n await human.detect(dom.video); // actual detection; were not capturing output in a local variable as it can also be reached via human.result\n const now = human.now();\n ok.detectFPS.val = Math.round(10000 / (now - timestamp.detect)) / 10;\n timestamp.detect = now;\n requestAnimationFrame(detectionLoop); // start new frame immediately\n }\n}\n\nfunction drawValidationTests() {\n let y = 32;\n for (const [key, val] of Object.entries(ok)) {\n let el = document.getElementById(`ok-${key}`);\n if (!el) {\n el = document.createElement('div');\n el.id = `ok-${key}`;\n el.innerText = key;\n el.className = 'ok';\n el.style.top = `${y}px`;\n dom.ok.appendChild(el);\n }\n if (typeof val.status === 'boolean') el.style.backgroundColor = val.status ? 'lightgreen' : 'lightcoral';\n const status = val.status ? 'ok' : 'fail';\n el.innerText = `${key}: ${val.val === 0 ? status : val.val}`;\n y += 28;\n }\n}\n\nasync function validationLoop(): Promise { // main screen refresh loop\n const interpolated = human.next(human.result); // smoothen result using last-known results\n human.draw.canvas(dom.video, dom.canvas); // draw canvas to screen\n await human.draw.all(dom.canvas, interpolated); // draw labels, boxes, lines, etc.\n const now = human.now();\n ok.drawFPS.val = Math.round(10000 / (now - timestamp.draw)) / 10;\n timestamp.draw = now;\n ok.faceCount.val = human.result.face.length;\n ok.faceCount.status = ok.faceCount.val === 1; // must be exactly detected face\n if (ok.faceCount.status) { // skip the rest if no face\n const gestures: string[] = Object.values(human.result.gesture).map((gesture: H.GestureResult) => gesture.gesture); // flatten all gestures\n if (gestures.includes('blink left eye') || gestures.includes('blink right eye')) blink.start = human.now(); // blink starts when eyes get closed\n if (blink.start > 0 && !gestures.includes('blink left eye') && !gestures.includes('blink right eye')) blink.end = human.now(); // if blink started how long until eyes are back open\n ok.blinkDetected.status = ok.blinkDetected.status || (Math.abs(blink.end - blink.start) > options.blinkMin && Math.abs(blink.end - blink.start) < options.blinkMax);\n if (ok.blinkDetected.status && blink.time === 0) blink.time = Math.trunc(blink.end - blink.start);\n ok.facingCenter.status = gestures.includes('facing center');\n ok.lookingCenter.status = gestures.includes('looking center'); // must face camera and look at camera\n ok.faceConfidence.val = human.result.face[0].faceScore || human.result.face[0].boxScore || 0;\n ok.faceConfidence.status = ok.faceConfidence.val >= options.minConfidence;\n ok.antispoofCheck.val = human.result.face[0].real || 0;\n ok.antispoofCheck.status = ok.antispoofCheck.val >= options.minConfidence;\n ok.livenessCheck.val = human.result.face[0].live || 0;\n ok.livenessCheck.status = ok.livenessCheck.val >= options.minConfidence;\n ok.faceSize.val = Math.min(human.result.face[0].box[2], human.result.face[0].box[3]);\n ok.faceSize.status = ok.faceSize.val >= options.minSize;\n ok.descriptor.val = human.result.face[0].embedding?.length || 0;\n ok.descriptor.status = ok.descriptor.val > 0;\n ok.age.val = human.result.face[0].age || 0;\n ok.age.status = ok.age.val > 0;\n ok.gender.val = human.result.face[0].genderScore || 0;\n ok.gender.status = ok.gender.val >= options.minConfidence;\n }\n // run again\n ok.timeout.status = ok.elapsedMs.val <= options.maxTime;\n drawValidationTests();\n if (allOk() || !ok.timeout.status) { // all criteria met\n dom.video.pause();\n return human.result.face[0];\n }\n ok.elapsedMs.val = Math.trunc(human.now() - startTime);\n return new Promise((resolve) => {\n setTimeout(async () => {\n await validationLoop(); // run validation loop until conditions are met\n resolve(human.result.face[0]); // recursive promise resolve\n }, 30); // use to slow down refresh from max refresh rate to target of 30 fps\n });\n}\n\nasync function saveRecords() {\n if (dom.name.value.length > 0) {\n const image = dom.canvas.getContext('2d')?.getImageData(0, 0, dom.canvas.width, dom.canvas.height) as ImageData;\n const rec = { id: 0, name: dom.name.value, descriptor: current.face?.embedding as number[], image };\n await indexDb.save(rec);\n log('saved face record:', rec.name, 'descriptor length:', current.face?.embedding?.length);\n log('known face records:', await indexDb.count());\n } else {\n log('invalid name');\n }\n}\n\nasync function deleteRecord() {\n if (current.record && current.record.id > 0) {\n await indexDb.remove(current.record);\n }\n}\n\nasync function detectFace() {\n dom.canvas.style.height = '';\n dom.canvas.getContext('2d')?.clearRect(0, 0, options.minSize, options.minSize);\n if (!current?.face?.tensor || !current?.face?.embedding) return false;\n console.log('face record:', current.face); // eslint-disable-line no-console\n log(`detected face: ${current.face.gender} ${current.face.age || 0}y distance ${current.face.iris || 0}cm/${Math.round(100 * (current.face.iris || 0) / 2.54) / 100}in`);\n human.tf.browser.toPixels(current.face.tensor as unknown as H.TensorLike, dom.canvas);\n if (await indexDb.count() === 0) {\n log('face database is empty: nothing to compare face with');\n document.body.style.background = 'black';\n dom.delete.style.display = 'none';\n return false;\n }\n const db = await indexDb.load();\n const descriptors = db.map((rec) => rec.descriptor).filter((desc) => desc.length > 0);\n const res = human.match(current.face.embedding, descriptors, matchOptions);\n current.record = db[res.index] || null;\n if (current.record) {\n log(`best match: ${current.record.name} | id: ${current.record.id} | similarity: ${Math.round(1000 * res.similarity) / 10}%`);\n dom.name.value = current.record.name;\n dom.source.style.display = '';\n dom.source.getContext('2d')?.putImageData(current.record.image, 0, 0);\n }\n document.body.style.background = res.similarity > options.threshold ? 'darkgreen' : 'maroon';\n return res.similarity > options.threshold;\n}\n\nasync function main() { // main entry point\n ok.faceCount.status = false;\n ok.faceConfidence.status = false;\n ok.facingCenter.status = false;\n ok.blinkDetected.status = false;\n ok.faceSize.status = false;\n ok.antispoofCheck.status = false;\n ok.livenessCheck.status = false;\n ok.age.status = false;\n ok.gender.status = false;\n ok.elapsedMs.val = 0;\n dom.match.style.display = 'none';\n dom.retry.style.display = 'none';\n dom.source.style.display = 'none';\n dom.canvas.style.height = '50%';\n document.body.style.background = 'black';\n await webCam();\n await detectionLoop(); // start detection loop\n startTime = human.now();\n current.face = await validationLoop(); // start validation loop\n dom.canvas.width = current.face.tensor?.shape[1] || options.minSize;\n dom.canvas.height = current.face.tensor?.shape[0] || options.minSize;\n dom.source.width = dom.canvas.width;\n dom.source.height = dom.canvas.height;\n dom.canvas.style.width = '';\n dom.match.style.display = 'flex';\n dom.save.style.display = 'flex';\n dom.delete.style.display = 'flex';\n dom.retry.style.display = 'block';\n if (!allOk()) { // is all criteria met?\n log('did not find valid face');\n return false;\n }\n return detectFace();\n}\n\nasync function init() {\n log('human version:', human.version, '| tfjs version:', human.tf.version['tfjs-core']);\n log('options:', JSON.stringify(options).replace(/{|}|\"|\\[|\\]/g, '').replace(/,/g, ' '));\n log('initializing webcam...');\n await webCam(); // start webcam\n log('loading human models...');\n await human.load(); // preload all models\n log('initializing human...');\n log('face embedding model:', humanConfig.face.description.enabled ? 'faceres' : '', humanConfig.face['mobilefacenet']?.enabled ? 'mobilefacenet' : '', humanConfig.face['insightface']?.enabled ? 'insightface' : '');\n log('loading face database...');\n log('known face records:', await indexDb.count());\n dom.retry.addEventListener('click', main);\n dom.save.addEventListener('click', saveRecords);\n dom.delete.addEventListener('click', deleteRecord);\n await human.warmup(); // warmup function to initialize backend for future faster detection\n await main();\n}\n\nwindow.onload = init;\n", "let db: IDBDatabase; // instance of indexdb\n\nconst database = 'human';\nconst table = 'person';\n\nexport interface FaceRecord { id: number, name: string, descriptor: number[], image: ImageData }\n\nconst log = (...msg) => console.log('indexdb', ...msg); // eslint-disable-line no-console\n\nexport async function open() {\n if (db) return true;\n return new Promise((resolve) => {\n const request: IDBOpenDBRequest = indexedDB.open(database, 1);\n request.onerror = (evt) => log('error:', evt);\n request.onupgradeneeded = (evt: IDBVersionChangeEvent) => { // create if doesnt exist\n log('create:', evt.target);\n db = (evt.target as IDBOpenDBRequest).result;\n db.createObjectStore(table, { keyPath: 'id', autoIncrement: true });\n };\n request.onsuccess = (evt) => { // open\n db = (evt.target as IDBOpenDBRequest).result;\n log('open:', db);\n resolve(true);\n };\n });\n}\n\nexport async function load(): Promise {\n const faceDB: FaceRecord[] = [];\n if (!db) await open(); // open or create if not already done\n return new Promise((resolve) => {\n const cursor: IDBRequest = db.transaction([table], 'readwrite').objectStore(table).openCursor(null, 'next');\n cursor.onerror = (evt) => log('load error:', evt);\n cursor.onsuccess = (evt) => {\n if ((evt.target as IDBRequest).result) {\n faceDB.push((evt.target as IDBRequest).result.value);\n (evt.target as IDBRequest).result.continue();\n } else {\n resolve(faceDB);\n }\n };\n });\n}\n\nexport async function count(): Promise {\n if (!db) await open(); // open or create if not already done\n return new Promise((resolve) => {\n const store: IDBRequest = db.transaction([table], 'readwrite').objectStore(table).count();\n store.onerror = (evt) => log('count error:', evt);\n store.onsuccess = () => resolve(store.result);\n });\n}\n\nexport async function save(faceRecord: FaceRecord) {\n if (!db) await open(); // open or create if not already done\n const newRecord = { name: faceRecord.name, descriptor: faceRecord.descriptor, image: faceRecord.image }; // omit id as its autoincrement\n db.transaction([table], 'readwrite').objectStore(table).put(newRecord);\n log('save:', newRecord);\n}\n\nexport async function remove(faceRecord: FaceRecord) {\n if (!db) await open(); // open or create if not already done\n db.transaction([table], 'readwrite').objectStore(table).delete(faceRecord.id); // delete based on id\n log('delete:', faceRecord);\n}\n"], + "mappings": ";;;;;;AASA,UAAYA,MAAO,0BCTnB,IAAIC,EAEEC,EAAW,QACXC,EAAQ,SAIRC,EAAM,IAAIC,IAAQ,QAAQ,IAAI,UAAW,GAAGA,CAAG,EAErD,eAAsBC,GAAO,CAC3B,OAAIL,EAAW,GACR,IAAI,QAASM,GAAY,CAC9B,IAAMC,EAA4B,UAAU,KAAKN,EAAU,CAAC,EAC5DM,EAAQ,QAAWC,GAAQL,EAAI,SAAUK,CAAG,EAC5CD,EAAQ,gBAAmBC,GAA+B,CACxDL,EAAI,UAAWK,EAAI,MAAM,EACzBR,EAAMQ,EAAI,OAA4B,OACtCR,EAAG,kBAAkBE,EAAO,CAAE,QAAS,KAAM,cAAe,EAAK,CAAC,CACpE,EACAK,EAAQ,UAAaC,GAAQ,CAC3BR,EAAMQ,EAAI,OAA4B,OACtCL,EAAI,QAASH,CAAE,EACfM,EAAQ,EAAI,CACd,CACF,CAAC,CACH,CAEA,eAAsBG,GAA8B,CAClD,IAAMC,EAAuB,CAAC,EAC9B,OAAKV,GAAI,MAAMK,EAAK,EACb,IAAI,QAASC,GAAY,CAC9B,IAAMK,EAAqBX,EAAG,YAAY,CAACE,CAAK,EAAG,WAAW,EAAE,YAAYA,CAAK,EAAE,WAAW,KAAM,MAAM,EAC1GS,EAAO,QAAWH,GAAQL,EAAI,cAAeK,CAAG,EAChDG,EAAO,UAAaH,GAAQ,CACrBA,EAAI,OAAsB,QAC7BE,EAAO,KAAMF,EAAI,OAAsB,OAAO,KAAK,EAClDA,EAAI,OAAsB,OAAO,SAAS,GAE3CF,EAAQ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7DM,EAAI,OAAO,MAAQA,EAAI,OAAO,MAC9BA,EAAI,OAAO,OAASA,EAAI,OAAO,OAC/BA,EAAI,OAAO,MAAM,MAAQ,GACzBA,EAAI,MAAM,MAAM,QAAU,OAC1BA,EAAI,KAAK,MAAM,QAAU,OACzBA,EAAI,OAAO,MAAM,QAAU,OAC3BA,EAAI,MAAM,MAAM,QAAU,QACrBJ,EAAM,EAIJqC,EAAW,GAHhB9B,EAAI,yBAAyB,EACtB,GAGX,CAEA,eAAeqC,GAAO,CArStB,IAAA7B,EAAAa,EAsSErB,EAAI,iBAAkBJ,EAAM,QAAS,kBAAmBA,EAAM,GAAG,QAAQ,YAAY,EACrFI,EAAI,WAAY,KAAK,UAAUT,CAAO,EAAE,QAAQ,eAAgB,EAAE,EAAE,QAAQ,KAAM,GAAG,CAAC,EACtFS,EAAI,wBAAwB,EAC5B,MAAME,EAAO,EACbF,EAAI,yBAAyB,EAC7B,MAAMJ,EAAM,KAAK,EACjBI,EAAI,uBAAuB,EAC3BA,EAAI,wBAAyBX,EAAY,KAAK,YAAY,QAAU,UAAY,IAAImB,EAAAnB,EAAY,KAAK,gBAAjB,MAAAmB,EAAmC,QAAU,gBAAkB,IAAIa,EAAAhC,EAAY,KAAK,cAAjB,MAAAgC,EAAiC,QAAU,cAAgB,EAAE,EACpNrB,EAAI,0BAA0B,EAC9BA,EAAI,sBAAuB,MAAc2B,EAAM,CAAC,EAChD9B,EAAI,MAAM,iBAAiB,QAASuC,CAAI,EACxCvC,EAAI,KAAK,iBAAiB,QAASuB,CAAW,EAC9CvB,EAAI,OAAO,iBAAiB,QAAS+B,CAAY,EACjD,MAAMhC,EAAM,OAAO,EACnB,MAAMwC,EAAK,CACb,CAEA,OAAO,OAASC", + "names": ["H", "db", "database", "table", "log", "msg", "open", "resolve", "request", "evt", "load", "faceDB", "cursor", "count", "store", "save", "faceRecord", "newRecord", "remove", "humanConfig", "matchOptions", "options", "ok", "allOk", "current", "blink", "human", "dom", "timestamp", "startTime", "log", "msg", "webCam", "cameraOptions", "stream", "ready", "resolve", "detectionLoop", "_a", "now", "drawValidationTests", "y", "key", "val", "el", "status", "validationLoop", "interpolated", "gestures", "gesture", "saveRecords", "_b", "_c", "_d", "image", "rec", "save", "count", "deleteRecord", "remove", "detectFace", "db", "load", "descriptors", "desc", "res", "main", "init"] } diff --git a/demo/faceid/index.ts b/demo/faceid/index.ts index aea5028f..b7507a23 100644 --- a/demo/faceid/index.ts +++ b/demo/faceid/index.ts @@ -11,6 +11,7 @@ import * as H from '../../dist/human.esm.js'; // equivalent of @vladmandic/Human import * as indexDb from './indexdb'; // methods to deal with indexdb const humanConfig = { // user configuration for human, used to fine-tune behavior + cacheSensitivity: 0, modelBasePath: '../../models', filter: { equalization: true }, // lets run with histogram equilizer face: { @@ -36,7 +37,7 @@ const matchOptions = { order: 2, multiplier: 25, min: 0.2, max: 0.8 }; // for fa const options = { minConfidence: 0.6, // overal face confidence for box, face, gender, real, live minSize: 224, // min input to face descriptor model before degradation - maxTime: 10000, // max time before giving up + maxTime: 30000, // max time before giving up blinkMin: 10, // minimum duration of a valid blink blinkMax: 800, // maximum duration of a valid blink threshold: 0.5, // minimum similarity @@ -46,18 +47,36 @@ const options = { ...matchOptions, }; -const ok = { // must meet all rules - faceCount: false, - faceConfidence: false, - facingCenter: false, - lookingCenter: false, - blinkDetected: false, - faceSize: false, - antispoofCheck: false, - livenessCheck: false, - elapsedMs: 0, // total time while waiting for valid face +const ok: Record = { // must meet all rules + faceCount: { status: false, val: 0 }, + faceConfidence: { status: false, val: 0 }, + facingCenter: { status: false, val: 0 }, + lookingCenter: { status: false, val: 0 }, + blinkDetected: { status: false, val: 0 }, + faceSize: { status: false, val: 0 }, + antispoofCheck: { status: false, val: 0 }, + livenessCheck: { status: false, val: 0 }, + age: { status: false, val: 0 }, + gender: { status: false, val: 0 }, + timeout: { status: true, val: 0 }, + descriptor: { status: false, val: 0 }, + elapsedMs: { status: undefined, val: 0 }, // total time while waiting for valid face + detectFPS: { status: undefined, val: 0 }, // mark detection fps performance + drawFPS: { status: undefined, val: 0 }, // mark redraw fps performance }; -const allOk = () => ok.faceCount && ok.faceSize && ok.blinkDetected && ok.facingCenter && ok.lookingCenter && ok.faceConfidence && ok.antispoofCheck && ok.livenessCheck; + +const allOk = () => ok.faceCount.status + && ok.faceSize.status + && ok.blinkDetected.status + && ok.facingCenter.status + && ok.lookingCenter.status + && ok.faceConfidence.status + && ok.antispoofCheck.status + && ok.livenessCheck.status + && ok.descriptor.status + && ok.age.status + && ok.gender.status; + const current: { face: H.FaceResult | null, record: indexDb.FaceRecord | null } = { face: null, record: null }; // current face record and matched database record const blink = { // internal timers for blink start/end/duration @@ -87,17 +106,14 @@ const dom = { // grab instances of dom objects so we dont have to look them up l ok: document.getElementById('ok') as HTMLDivElement, }; const timestamp = { detect: 0, draw: 0 }; // holds information used to calculate performance and possible memory leaks -const fps = { detect: 0, draw: 0 }; // holds calculated fps information for both detect and screen refresh let startTime = 0; const log = (...msg) => { // helper method to output messages dom.log.innerText += msg.join(' ') + '\n'; console.log(...msg); // eslint-disable-line no-console }; -const printFPS = (msg) => dom.fps.innerText = msg; // print status element async function webCam() { // initialize webcam - printFPS('starting webcam...'); // @ts-ignore resizeMode is not yet defined in tslib const cameraOptions: MediaStreamConstraints = { audio: false, video: { facingMode: 'user', resizeMode: 'none', width: { ideal: document.body.clientWidth } } }; const stream: MediaStream = await navigator.mediaDevices.getUserMedia(cameraOptions); @@ -107,6 +123,8 @@ async function webCam() { // initialize webcam await ready; dom.canvas.width = dom.video.videoWidth; dom.canvas.height = dom.video.videoHeight; + dom.canvas.style.width = '50%'; + dom.canvas.style.height = '50%'; if (human.env.initial) log('video:', dom.video.videoWidth, dom.video.videoHeight, '|', stream.getVideoTracks()[0].label); dom.canvas.onclick = () => { // pause when clicked on screen and resume on next click if (dom.video.paused) void dom.video.play(); @@ -119,58 +137,71 @@ async function detectionLoop() { // main detection loop if (current.face?.tensor) human.tf.dispose(current.face.tensor); // dispose previous tensor await human.detect(dom.video); // actual detection; were not capturing output in a local variable as it can also be reached via human.result const now = human.now(); - fps.detect = 1000 / (now - timestamp.detect); + ok.detectFPS.val = Math.round(10000 / (now - timestamp.detect)) / 10; timestamp.detect = now; requestAnimationFrame(detectionLoop); // start new frame immediately } } +function drawValidationTests() { + let y = 32; + for (const [key, val] of Object.entries(ok)) { + let el = document.getElementById(`ok-${key}`); + if (!el) { + el = document.createElement('div'); + el.id = `ok-${key}`; + el.innerText = key; + el.className = 'ok'; + el.style.top = `${y}px`; + dom.ok.appendChild(el); + } + if (typeof val.status === 'boolean') el.style.backgroundColor = val.status ? 'lightgreen' : 'lightcoral'; + const status = val.status ? 'ok' : 'fail'; + el.innerText = `${key}: ${val.val === 0 ? status : val.val}`; + y += 28; + } +} + async function validationLoop(): Promise { // main screen refresh loop const interpolated = human.next(human.result); // smoothen result using last-known results human.draw.canvas(dom.video, dom.canvas); // draw canvas to screen await human.draw.all(dom.canvas, interpolated); // draw labels, boxes, lines, etc. const now = human.now(); - fps.draw = 1000 / (now - timestamp.draw); + ok.drawFPS.val = Math.round(10000 / (now - timestamp.draw)) / 10; timestamp.draw = now; - printFPS(`fps: ${fps.detect.toFixed(1).padStart(5, ' ')} detect | ${fps.draw.toFixed(1).padStart(5, ' ')} draw`); // write status - ok.faceCount = human.result.face.length === 1; // must be exactly detected face - if (ok.faceCount) { // skip the rest if no face + ok.faceCount.val = human.result.face.length; + ok.faceCount.status = ok.faceCount.val === 1; // must be exactly detected face + if (ok.faceCount.status) { // skip the rest if no face const gestures: string[] = Object.values(human.result.gesture).map((gesture: H.GestureResult) => gesture.gesture); // flatten all gestures if (gestures.includes('blink left eye') || gestures.includes('blink right eye')) blink.start = human.now(); // blink starts when eyes get closed if (blink.start > 0 && !gestures.includes('blink left eye') && !gestures.includes('blink right eye')) blink.end = human.now(); // if blink started how long until eyes are back open - ok.blinkDetected = ok.blinkDetected || (Math.abs(blink.end - blink.start) > options.blinkMin && Math.abs(blink.end - blink.start) < options.blinkMax); - if (ok.blinkDetected && blink.time === 0) blink.time = Math.trunc(blink.end - blink.start); - ok.facingCenter = gestures.includes('facing center'); - ok.lookingCenter = gestures.includes('looking center'); // must face camera and look at camera - ok.faceConfidence = (human.result.face[0].boxScore || 0) > options.minConfidence && (human.result.face[0].faceScore || 0) > options.minConfidence; - ok.antispoofCheck = (human.result.face[0].real || 0) > options.minConfidence; - ok.livenessCheck = (human.result.face[0].live || 0) > options.minConfidence; - ok.faceSize = human.result.face[0].box[2] >= options.minSize && human.result.face[0].box[3] >= options.minSize; - } - let y = 32; - for (const [key, val] of Object.entries(ok)) { - let el = document.getElementById(`ok-${key}`); - if (!el) { - el = document.createElement('div'); - el.innerText = key; - el.className = 'ok'; - el.style.top = `${y}px`; - dom.ok.appendChild(el); - } - if (typeof val === 'boolean') el.style.backgroundColor = val ? 'lightgreen' : 'lightcoral'; - else el.innerText = `${key}:${val}`; - y += 28; - } - if (allOk()) { // all criteria met - dom.video.pause(); - return human.result.face[0]; - } - if (ok.elapsedMs > options.maxTime) { // give up - dom.video.pause(); - return human.result.face[0]; + ok.blinkDetected.status = ok.blinkDetected.status || (Math.abs(blink.end - blink.start) > options.blinkMin && Math.abs(blink.end - blink.start) < options.blinkMax); + if (ok.blinkDetected.status && blink.time === 0) blink.time = Math.trunc(blink.end - blink.start); + ok.facingCenter.status = gestures.includes('facing center'); + ok.lookingCenter.status = gestures.includes('looking center'); // must face camera and look at camera + ok.faceConfidence.val = human.result.face[0].faceScore || human.result.face[0].boxScore || 0; + ok.faceConfidence.status = ok.faceConfidence.val >= options.minConfidence; + ok.antispoofCheck.val = human.result.face[0].real || 0; + ok.antispoofCheck.status = ok.antispoofCheck.val >= options.minConfidence; + ok.livenessCheck.val = human.result.face[0].live || 0; + ok.livenessCheck.status = ok.livenessCheck.val >= options.minConfidence; + ok.faceSize.val = Math.min(human.result.face[0].box[2], human.result.face[0].box[3]); + ok.faceSize.status = ok.faceSize.val >= options.minSize; + ok.descriptor.val = human.result.face[0].embedding?.length || 0; + ok.descriptor.status = ok.descriptor.val > 0; + ok.age.val = human.result.face[0].age || 0; + ok.age.status = ok.age.val > 0; + ok.gender.val = human.result.face[0].genderScore || 0; + ok.gender.status = ok.gender.val >= options.minConfidence; } // run again - ok.elapsedMs = Math.trunc(human.now() - startTime); + ok.timeout.status = ok.elapsedMs.val <= options.maxTime; + drawValidationTests(); + if (allOk() || !ok.timeout.status) { // all criteria met + dom.video.pause(); + return human.result.face[0]; + } + ok.elapsedMs.val = Math.trunc(human.now() - startTime); return new Promise((resolve) => { setTimeout(async () => { await validationLoop(); // run validation loop until conditions are met @@ -198,12 +229,14 @@ async function deleteRecord() { } async function detectFace() { + dom.canvas.style.height = ''; dom.canvas.getContext('2d')?.clearRect(0, 0, options.minSize, options.minSize); if (!current?.face?.tensor || !current?.face?.embedding) return false; console.log('face record:', current.face); // eslint-disable-line no-console + log(`detected face: ${current.face.gender} ${current.face.age || 0}y distance ${current.face.iris || 0}cm/${Math.round(100 * (current.face.iris || 0) / 2.54) / 100}in`); human.tf.browser.toPixels(current.face.tensor as unknown as H.TensorLike, dom.canvas); if (await indexDb.count() === 0) { - log('face database is empty'); + log('face database is empty: nothing to compare face with'); document.body.style.background = 'black'; dom.delete.style.display = 'none'; return false; @@ -223,17 +256,20 @@ async function detectFace() { } async function main() { // main entry point - ok.faceCount = false; - ok.faceConfidence = false; - ok.facingCenter = false; - ok.blinkDetected = false; - ok.faceSize = false; - ok.antispoofCheck = false; - ok.livenessCheck = false; - ok.elapsedMs = 0; + ok.faceCount.status = false; + ok.faceConfidence.status = false; + ok.facingCenter.status = false; + ok.blinkDetected.status = false; + ok.faceSize.status = false; + ok.antispoofCheck.status = false; + ok.livenessCheck.status = false; + ok.age.status = false; + ok.gender.status = false; + ok.elapsedMs.val = 0; dom.match.style.display = 'none'; dom.retry.style.display = 'none'; dom.source.style.display = 'none'; + dom.canvas.style.height = '50%'; document.body.style.background = 'black'; await webCam(); await detectionLoop(); // start detection loop @@ -257,13 +293,15 @@ async function main() { // main entry point async function init() { log('human version:', human.version, '| tfjs version:', human.tf.version['tfjs-core']); - log('face embedding model:', humanConfig.face.description.enabled ? 'faceres' : '', humanConfig.face['mobilefacenet']?.enabled ? 'mobilefacenet' : '', humanConfig.face['insightface']?.enabled ? 'insightface' : ''); log('options:', JSON.stringify(options).replace(/{|}|"|\[|\]/g, '').replace(/,/g, ' ')); - printFPS('loading...'); - log('known face records:', await indexDb.count()); + log('initializing webcam...'); await webCam(); // start webcam + log('loading human models...'); await human.load(); // preload all models - printFPS('initializing...'); + log('initializing human...'); + log('face embedding model:', humanConfig.face.description.enabled ? 'faceres' : '', humanConfig.face['mobilefacenet']?.enabled ? 'mobilefacenet' : '', humanConfig.face['insightface']?.enabled ? 'insightface' : ''); + log('loading face database...'); + log('known face records:', await indexDb.count()); dom.retry.addEventListener('click', main); dom.save.addEventListener('click', saveRecords); dom.delete.addEventListener('click', deleteRecord); diff --git a/package.json b/package.json index 9f8c017a..7bd378ed 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "@tensorflow/tfjs-node": "^3.20.0", "@tensorflow/tfjs-node-gpu": "^3.20.0", "@tensorflow/tfjs-tflite": "0.0.1-alpha.8", - "@types/node": "^18.7.20", + "@types/node": "^18.7.21", "@types/offscreencanvas": "^2019.7.0", "@typescript-eslint/eslint-plugin": "^5.38.0", "@typescript-eslint/parser": "^5.38.0", diff --git a/test/build.log b/test/build.log index 58678654..b6f93fb1 100644 --- a/test/build.log +++ b/test/build.log @@ -1,39 +1,39 @@ -2022-09-24 11:38:12 DATA:  Build {"name":"@vladmandic/human","version":"2.10.3"} -2022-09-24 11:38:12 INFO:  Application: {"name":"@vladmandic/human","version":"2.10.3"} -2022-09-24 11:38:12 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true} -2022-09-24 11:38:12 INFO:  Toolchain: {"build":"0.7.13","esbuild":"0.15.9","typescript":"4.8.3","typedoc":"0.23.15","eslint":"8.24.0"} -2022-09-24 11:38:12 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]} -2022-09-24 11:38:12 STATE: Clean: {"locations":["dist/*","types/lib/*","typedoc/*"]} -2022-09-24 11:38:12 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":159,"outputBytes":608} -2022-09-24 11:38:12 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":75,"inputBytes":658536,"outputBytes":309564} -2022-09-24 11:38:12 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":167,"outputBytes":612} -2022-09-24 11:38:12 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":75,"inputBytes":658540,"outputBytes":309568} -2022-09-24 11:38:12 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":206,"outputBytes":664} -2022-09-24 11:38:12 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":75,"inputBytes":658592,"outputBytes":309618} -2022-09-24 11:38:12 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1125,"outputBytes":358} -2022-09-24 11:38:12 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":1088,"outputBytes":583} -2022-09-24 11:38:12 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":75,"inputBytes":658511,"outputBytes":308423} -2022-09-24 11:38:12 STATE: Compile: {"name":"tfjs/browser/esm/custom","format":"esm","platform":"browser","input":"tfjs/tf-custom.ts","output":"dist/tfjs.esm.js","files":11,"inputBytes":1344,"outputBytes":2821914} -2022-09-24 11:38:12 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":75,"inputBytes":3479842,"outputBytes":1688553} -2022-09-24 11:38:12 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":75,"inputBytes":3479842,"outputBytes":3110385} -2022-09-24 11:38:17 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":15} -2022-09-24 11:38:19 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":77,"generated":true} -2022-09-24 11:38:19 STATE: Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":6714,"outputBytes":3134} -2022-09-24 11:38:19 STATE: Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":15488,"outputBytes":7788} -2022-09-24 11:38:29 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":110,"errors":0,"warnings":0} -2022-09-24 11:38:29 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"} -2022-09-24 11:38:29 STATE: Copy: {"input":"tfjs/tfjs.esm.d.ts"} -2022-09-24 11:38:29 INFO:  Done... -2022-09-24 11:38:30 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":193} -2022-09-24 11:38:30 STATE: Copy: {"input":"types/human.d.ts"} -2022-09-24 11:38:30 INFO:  Analyze models: {"folders":8,"result":"models/models.json"} -2022-09-24 11:38:30 STATE: Models {"folder":"./models","models":13} -2022-09-24 11:38:30 STATE: Models {"folder":"../human-models/models","models":42} -2022-09-24 11:38:30 STATE: Models {"folder":"../blazepose/model/","models":4} -2022-09-24 11:38:30 STATE: Models {"folder":"../anti-spoofing/model","models":1} -2022-09-24 11:38:30 STATE: Models {"folder":"../efficientpose/models","models":3} -2022-09-24 11:38:30 STATE: Models {"folder":"../insightface/models","models":5} -2022-09-24 11:38:30 STATE: Models {"folder":"../movenet/models","models":3} -2022-09-24 11:38:30 STATE: Models {"folder":"../nanodet/models","models":4} -2022-09-24 11:38:31 STATE: Models: {"count":57,"totalSize":383017442} -2022-09-24 11:38:31 INFO:  Human Build complete... {"logFile":"test/build.log"} +2022-09-25 10:14:55 DATA:  Build {"name":"@vladmandic/human","version":"2.10.3"} +2022-09-25 10:14:55 INFO:  Application: {"name":"@vladmandic/human","version":"2.10.3"} +2022-09-25 10:14:55 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true} +2022-09-25 10:14:55 INFO:  Toolchain: {"build":"0.7.13","esbuild":"0.15.9","typescript":"4.8.3","typedoc":"0.23.15","eslint":"8.24.0"} +2022-09-25 10:14:55 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]} +2022-09-25 10:14:55 STATE: Clean: {"locations":["dist/*","types/lib/*","typedoc/*"]} +2022-09-25 10:14:55 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":159,"outputBytes":608} +2022-09-25 10:14:55 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":75,"inputBytes":658536,"outputBytes":309564} +2022-09-25 10:14:55 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":167,"outputBytes":612} +2022-09-25 10:14:55 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":75,"inputBytes":658540,"outputBytes":309568} +2022-09-25 10:14:55 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":206,"outputBytes":664} +2022-09-25 10:14:55 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":75,"inputBytes":658592,"outputBytes":309618} +2022-09-25 10:14:55 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1125,"outputBytes":358} +2022-09-25 10:14:55 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":1088,"outputBytes":583} +2022-09-25 10:14:55 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":75,"inputBytes":658511,"outputBytes":308423} +2022-09-25 10:14:55 STATE: Compile: {"name":"tfjs/browser/esm/custom","format":"esm","platform":"browser","input":"tfjs/tf-custom.ts","output":"dist/tfjs.esm.js","files":11,"inputBytes":1344,"outputBytes":2821914} +2022-09-25 10:14:55 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":75,"inputBytes":3479842,"outputBytes":1688553} +2022-09-25 10:14:56 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":75,"inputBytes":3479842,"outputBytes":3110385} +2022-09-25 10:15:00 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":15} +2022-09-25 10:15:02 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":77,"generated":true} +2022-09-25 10:15:02 STATE: Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":6714,"outputBytes":3134} +2022-09-25 10:15:02 STATE: Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":17155,"outputBytes":9175} +2022-09-25 10:15:13 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":110,"errors":0,"warnings":0} +2022-09-25 10:15:14 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"} +2022-09-25 10:15:14 STATE: Copy: {"input":"tfjs/tfjs.esm.d.ts"} +2022-09-25 10:15:14 INFO:  Done... +2022-09-25 10:15:14 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":193} +2022-09-25 10:15:14 STATE: Copy: {"input":"types/human.d.ts"} +2022-09-25 10:15:14 INFO:  Analyze models: {"folders":8,"result":"models/models.json"} +2022-09-25 10:15:14 STATE: Models {"folder":"./models","models":13} +2022-09-25 10:15:14 STATE: Models {"folder":"../human-models/models","models":42} +2022-09-25 10:15:14 STATE: Models {"folder":"../blazepose/model/","models":4} +2022-09-25 10:15:14 STATE: Models {"folder":"../anti-spoofing/model","models":1} +2022-09-25 10:15:14 STATE: Models {"folder":"../efficientpose/models","models":3} +2022-09-25 10:15:14 STATE: Models {"folder":"../insightface/models","models":5} +2022-09-25 10:15:14 STATE: Models {"folder":"../movenet/models","models":3} +2022-09-25 10:15:14 STATE: Models {"folder":"../nanodet/models","models":4} +2022-09-25 10:15:15 STATE: Models: {"count":57,"totalSize":383017442} +2022-09-25 10:15:15 INFO:  Human Build complete... {"logFile":"test/build.log"} diff --git a/wiki b/wiki index cf9ea492..c90beada 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit cf9ea4929d720dcb4e1b25a6b7c1fb4c5b4d2718 +Subproject commit c90beadaf77a71df5c25c08d878ad2b6913b15dd