xxxxxxxxxx
43
var ctracker = null;
let capture = null;
let capWidth = 640;
let capHeight = 480;
function setup() {
var cnv = createCanvas(capWidth, capHeight);
capture = createCapture(VIDEO);
capture.size(capWidth, capHeight);
capture.hide();
pixelDensity(1);
ctracker = new clm.tracker();
ctracker.init();
ctracker.start(capture.elt);
noStroke();
}
function draw() {
clear();
push();
translate(width, 0);
scale(-1, 1);
image(capture, 0, 0, width, height);
pop();
// get array of face marker positions [x, y] format
var positions = ctracker.getCurrentPosition();
for (var i = 0; i < positions.length; i++) {
// set the color of the ellipse based on position on screen
fill(map(positions[i][0], width * 0.33, width * 0.66, 0, 255), map(positions[i][1], height * 0.33, height * 0.66, 0, 255), 255);
// fill(150)
// draw ellipse at each position point
ellipse(width - positions[i][0], positions[i][1], 8, 8);
}
}