xxxxxxxxxx
52
// Based on https://kylemcdonald.github.io/cv-examples/
// original from Check https://github.com/auduno/clmtrackr
var capture;
var tracker;
var w = 640;
var h = 480;
function setup() {
capture = createCapture({
audio: false,
video: {
deviceId: '2dcd9cc7e0e39f10346178cd8d42ffcfd7c73fd05bb98d8562acba5c6b3e7ecf',
width: w,
height: h
}
}, function() {
console.log('success: capture ready.')
});
//capture.elt.setAttribute('playsinline', '');
createCanvas(w, h);
capture.size(w, h);
capture.hide();
tracker = new clm.tracker();
tracker.init();
tracker.start(capture.elt);
}
function draw() {
background(100);
image(capture, 0, 0, w, h);
text(str(frameRate()), 20,20);
var positions = tracker.getCurrentPosition();
console.log(positions);
noFill();
stroke(255);
strokeWeight(2);
beginShape();
if (positions.length > 0) {
for (var i = 0; i < positions.length; i++) {
vertex(positions[i][0], positions[i][1]);
}
}
endShape();
}