parent
ee4bbe8749
commit
586dcdf477
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -5,7 +5,7 @@ const modelPath = 'https://vladmandic.github.io/face-api/model/'; // path to mod
|
|||
// const modelPath = '../model/'; // path to model folder that will be loaded using http
|
||||
const imgSize = 512; // maximum image size in pixels
|
||||
const minScore = 0.1; // minimum score
|
||||
const maxResults = 5; // maximum number of results to return
|
||||
const maxResults = 10; // maximum number of results to return
|
||||
const samples = ['sample (1).jpg', 'sample (2).jpg', 'sample (3).jpg', 'sample (4).jpg', 'sample (5).jpg', 'sample (6).jpg']; // sample images to be loaded using http
|
||||
|
||||
// helper function to pretty-print json object to string
|
||||
|
@ -122,8 +122,8 @@ async function main() {
|
|||
await faceapi.tf.ready();
|
||||
|
||||
// check version
|
||||
log(`Version: TensorFlow/JS ${str(faceapi.tf?.version_core || '(not loaded)')} FaceAPI ${str(faceapi?.version || '(not loaded)')} Backend: ${str(faceapi.tf?.getBackend() || '(not loaded)')}`);
|
||||
log(`Flags: ${JSON.stringify(faceapi.tf.ENV.flags)}`);
|
||||
log(`Version: FaceAPI ${str(faceapi?.version.faceapi || '(not loaded)')} TensorFlow/JS ${str(faceapi?.tf?.version_core || '(not loaded)')} Backend: ${str(faceapi?.tf?.getBackend() || '(not loaded)')}`);
|
||||
log(`Flags: ${JSON.stringify(faceapi?.tf?.ENV.flags || { tf: 'not loaded' })}`);
|
||||
|
||||
// load face-api models
|
||||
log('Loading FaceAPI models');
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=yes">
|
||||
<script src="./webcam.js" type="module"></script>
|
||||
</head>
|
||||
<body style="font-family: monospace; background: black; color: white; font-size: 16px; line-height: 22px; margin: 0;">
|
||||
<body style="font-family: monospace; background: black; color: white; font-size: 16px; line-height: 22px; margin: 0; overflow: hidden">
|
||||
<video id="video" playsinline class="video"></video>
|
||||
<canvas id="canvas" class="canvas" style="position: fixed; top: 0; left: 0; z-index: 10"></canvas>
|
||||
<div id="log"></div>
|
||||
<div id="log" style="overflow-y: scroll; height: 16.5rem"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -116,6 +116,17 @@ async function setupCamera() {
|
|||
const settings = track.getSettings();
|
||||
log(`Camera active: ${track.label} ${str(constraints)}`);
|
||||
log(`Camera settings: ${str(settings)}`);
|
||||
canvas.addEventListener('click', () => {
|
||||
// @ts-ignore
|
||||
if (video && video.readyState >= 2) {
|
||||
// @ts-ignore
|
||||
if (video.paused) video.play();
|
||||
// @ts-ignore
|
||||
else video.pause();
|
||||
}
|
||||
// @ts-ignore
|
||||
log(`Camera state: ${video.paused ? 'paused' : 'playing'}`);
|
||||
});
|
||||
return new Promise((resolve) => {
|
||||
video.onloadeddata = async () => {
|
||||
// @ts-ignore
|
||||
|
@ -162,8 +173,8 @@ async function main() {
|
|||
await faceapi.tf.ready();
|
||||
|
||||
// check version
|
||||
log(`Version: TensorFlow/JS ${str(faceapi.tf?.version_core || '(not loaded)')} FaceAPI ${str(faceapi?.version || '(not loaded)')} Backend: ${str(faceapi.tf?.getBackend() || '(not loaded)')}`);
|
||||
log(`Flags: ${str(faceapi.tf.ENV.flags)}`);
|
||||
log(`Version: FaceAPI ${str(faceapi?.version.faceapi || '(not loaded)')} TensorFlow/JS ${str(faceapi?.tf?.version_core || '(not loaded)')} Backend: ${str(faceapi?.tf?.getBackend() || '(not loaded)')}`);
|
||||
log(`Flags: ${JSON.stringify(faceapi?.tf?.ENV.flags || { tf: 'not loaded' })}`);
|
||||
|
||||
setupFaceAPI();
|
||||
setupCamera();
|
||||
|
|
Loading…
Reference in New Issue