From 9e90aada9419833b83f5efb5951d995247c27be2 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Mon, 28 Sep 2020 13:18:32 +0200 Subject: [PATCH] test frame chaching --- dist/static/assets/webcam.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dist/static/assets/webcam.js b/dist/static/assets/webcam.js index d9029277..bc2fb48c 100644 --- a/dist/static/assets/webcam.js +++ b/dist/static/assets/webcam.js @@ -96,6 +96,7 @@ var drawMask = function(detection) { let faceapi; var video; var lastFrame; +var frameToDetect; var detections = []; var factor_x, factor_y; @@ -145,6 +146,7 @@ function setup() { video = createCapture(constraints); lastFrame = createGraphics(video.width, video.height); + frameToDetect = createGraphics(video.width, video.height); // console.log(video); // HeadGazeSetup(video); @@ -157,6 +159,7 @@ function setup() { } function modelReady() { + frameToDetect.image(video, 0,0, video.width, video.height); faceapi.detect(gotResults); } @@ -175,16 +178,19 @@ gotResults = function(err, result) { // store data for async draw function // TODO results to more compatible format + + lastFrame.image(frameToDetect, 0,0, video.width, video.height); detections = parseDetectionResults(result); // size of video becomes known only after camera approval if(lastFrame.width != video.width || lastFrame.height != video.height){ // console.log('Resizing canvas'); lastFrame.resizeCanvas(video.width, video.height); + frameToDetect.resizeCanvas(video.width, video.height); } // lastFrame.background('red'); - lastFrame.image(video, 0,0, video.width, video.height); + frameToDetect.image(video, 0,0, video.width, video.height); factor_x = width / video.width; factor_y = height / video.height;