xxxxxxxxxx
37
var capture;
var tracker
var w = 400,
h = 400;
function setup() {
capture = createCapture({
audio: false,
video: {
width: w,
height: h
}
}, function() {
console.log('capture ready.')
});
createCanvas(w, h);
capture.size(w, h);
capture.hide();
tracker = new clm.tracker();
tracker.init();
tracker.start(capture.elt);
}
function draw() {
image(capture, 0, 0, w, h);
var positions = tracker.getCurrentPosition();
// Check if there is anything in the positions array
// before trying to use it for anything.
if (positions.length > 0) {
noStroke();
fill("red");
// the numbers at positions[62] represent the tip of the nose
ellipse(positions[62][0], positions[62][1], 25, 40);
}
}