test frame chaching
This commit is contained in:
parent
f1a60d4dee
commit
9e90aada94
1 changed files with 7 additions and 1 deletions
8
dist/static/assets/webcam.js
vendored
8
dist/static/assets/webcam.js
vendored
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue