xxxxxxxxxx
56
// p5.js + BRFv4 face tracker (via handsfree.js)
//
// We're using a specific version of handsfree.js
// that has the (commercial, trial) BRFv4 tracker baked in:
// https://unpkg.com/handsfree@4.0.3/dist/handsfree.js
// more information about the BRFv4 tracker is at:
// https://github.com/Tastenkunst/brfv4_javascript_examples
var myHandsfree;
class Point {
constructor(x=0, y=0) {
this.x = x, this.y = y;
}
}
//---------------------------------------------
function setup() {
createCanvas(640, 480);
var myConfig = {
hideCursor: true
};
myHandsfree = new Handsfree(myConfig);
myHandsfree.start();
}
//---------------------------------------------
function draw() {
background(0, 0, 0);
if (myHandsfree.isTracking) {
if (myHandsfree.pose.length > 0) {
var face0 = myHandsfree.pose[0].face;
var nPoints = face0.vertices.length;
fill(255, 0, 0);
for (var i = 0; i < 34; i += 2) {
tempPoint = new Point (face0.vertices[i + 0],face0.vertices[i + 1]);
ellipse(tempPoint.x, tempPoint.y, 9);
}
//for point in pointArray
//fill peach color
//create a traiangle with point 0, point i, point i + 1
// Rotations of the head, in radians
var rx = face0.rotationX; // pitch
var ry = face0.rotationY; // yaw
var rz = face0.rotationZ; // roll
}
}
}