From cab689f05a3499b65cdf30bc89a0587b75bb49c4 Mon Sep 17 00:00:00 2001 From: joeyklee Date: Fri, 11 Oct 2019 18:41:36 -0400 Subject: [PATCH] rm faceapi examples with expressions --- .../FaceApi/FaceApi_Image_Landmarks/sketch.js | 1 - .../FaceApi_Video_Expressions/index.html | 17 --- .../FaceApi_Video_Expressions/sketch.js | 103 ------------------ .../FaceApi/FaceApi_Video_Landmarks/sketch.js | 1 - .../sketch.js | 2 - 5 files changed, 124 deletions(-) delete mode 100644 javascript/FaceApi/FaceApi_Video_Expressions/index.html delete mode 100644 javascript/FaceApi/FaceApi_Video_Expressions/sketch.js diff --git a/javascript/FaceApi/FaceApi_Image_Landmarks/sketch.js b/javascript/FaceApi/FaceApi_Image_Landmarks/sketch.js index 5d8fa0be..5d01408c 100644 --- a/javascript/FaceApi/FaceApi_Image_Landmarks/sketch.js +++ b/javascript/FaceApi/FaceApi_Image_Landmarks/sketch.js @@ -8,7 +8,6 @@ let canvas, ctx; // by default all options are set to true const detection_options = { withLandmarks: true, - withExpressions: false, withDescriptors: false, } diff --git a/javascript/FaceApi/FaceApi_Video_Expressions/index.html b/javascript/FaceApi/FaceApi_Video_Expressions/index.html deleted file mode 100644 index b8d98a63..00000000 --- a/javascript/FaceApi/FaceApi_Video_Expressions/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - FaceApi Expressions Demo - - - - - - - - -

FaceApi Expressions Demo

- - - \ No newline at end of file diff --git a/javascript/FaceApi/FaceApi_Video_Expressions/sketch.js b/javascript/FaceApi/FaceApi_Video_Expressions/sketch.js deleted file mode 100644 index 4a51b1c1..00000000 --- a/javascript/FaceApi/FaceApi_Video_Expressions/sketch.js +++ /dev/null @@ -1,103 +0,0 @@ -let faceapi; -let video; -let detections; -let width = 360; -let height = 276; -let canvas, ctx; - -// by default all options are set to true -const detection_options = { - withLandmarks: false, - withExpressions: true, - withDescriptors: true, -} - -async function make() { - canvas = createCanvas(width, height); - ctx = canvas.getContext('2d'); - // load up your video - video = await getVideo(); - - // video.hide(); // Hide the video element, and just show the canvas - faceapi = await ml5.faceApi(video, detection_options, modelReady) -} - -// call app.map.init() once the DOM is loaded -window.addEventListener('DOMContentLoaded', function () { - make(); -}); - -function modelReady() { - console.log('ready!') - console.log(faceapi) - - faceapi.detect(gotResults) - -} - - -// Helper Functions -async function getVideo() { - // Grab elements, create settings, etc. - const videoElement = document.createElement('video'); - videoElement.setAttribute("style", "display: inline-block;"); - videoElement.width = width; - videoElement.height = height; - document.body.appendChild(videoElement); - - // Create a webcam capture - const capture = await navigator.mediaDevices.getUserMedia({ - video: true - }) - videoElement.srcObject = capture; - videoElement.play(); - - return videoElement -} - - -function gotResults(err, result) { - if (err) { - console.log(err) - return - } - // console.log(result) - detections = result; - - // Clear part of the canvas - ctx.fillStyle = "#FFFFFF" - ctx.fillRect(0, 0, width, height); - ctx.textAlign = "right"; - - if (detections) { - if (detections.length > 0) { - const expressions = detections[0].expressions; - - let keys = Object.keys(expressions); - for (let i = 0; i < keys.length; i++) { - ctx.fillStyle = "#000000" - ctx.font = "10px Arial"; - ctx.fillText(`${keys[i]}:`, 70, i * 20 + 20) - const val = scale(expressions[keys[i]], 0, 1, 0, width / 2) - - ctx.fillRect(80, i * 20 + 10, val, 15); - } - } - - } - faceapi.detect(gotResults) -} - -function scale(num, in_min, in_max, out_min, out_max) { - return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; -} - - -// Helper Functions -function createCanvas(w, h) { - const canvas = document.createElement("canvas"); - canvas.width = w; - canvas.height = h; - document.body.appendChild(canvas); - return canvas; -} \ No newline at end of file diff --git a/javascript/FaceApi/FaceApi_Video_Landmarks/sketch.js b/javascript/FaceApi/FaceApi_Video_Landmarks/sketch.js index ae30b32e..98181876 100644 --- a/javascript/FaceApi/FaceApi_Video_Landmarks/sketch.js +++ b/javascript/FaceApi/FaceApi_Video_Landmarks/sketch.js @@ -8,7 +8,6 @@ let canvas, ctx; // by default all options are set to true const detection_options = { withLandmarks: true, - withExpressions: false, withDescriptors: false, } diff --git a/javascript/FaceApi/FaceApi_Video_Landmarks_LocalModels/sketch.js b/javascript/FaceApi/FaceApi_Video_Landmarks_LocalModels/sketch.js index 5f29808b..188142e7 100644 --- a/javascript/FaceApi/FaceApi_Video_Landmarks_LocalModels/sketch.js +++ b/javascript/FaceApi/FaceApi_Video_Landmarks_LocalModels/sketch.js @@ -8,12 +8,10 @@ let canvas, ctx; // relative path to your models from window.location.pathname const detection_options = { withLandmarks: true, - withExpressions: false, withDescriptors: false, Mobilenetv1Model: 'models', FaceLandmarkModel: 'models', FaceRecognitionModel: 'models', - FaceExpressionModel: 'models', }