update webcam.js

This commit is contained in:
Ruben van de Ven 2020-09-25 13:19:01 +02:00
parent 37d60fd576
commit fce40f28bb

View file

@ -191,48 +191,44 @@ function drawLandmarks(detection) {
const leftEyeBrow = detection.parts.leftEyeBrow; const leftEyeBrow = detection.parts.leftEyeBrow;
const jawOutline = detection.parts.jawOutline; const jawOutline = detection.parts.jawOutline;
drawPart(mouth, true); strokePoints(mouth, CLOSE);
drawPart(nose, true); strokePoints(nose, CLOSE);
drawPart(leftEye, true); strokePoints(leftEye, CLOSE);
drawPart(leftEyeBrow, false); strokePoints(leftEyeBrow, OPEN);
drawPart(rightEye, true); strokePoints(rightEye, CLOSE);
drawPart(rightEyeBrow, false); strokePoints(rightEyeBrow, OPEN);
drawPart(jawOutline, false); strokePoints(jawOutline, OPEN);
// } // }
} }
function drawPart(feature, closed) { function strokePoints(points, closed) {
beginShape(); beginShape();
for (let i = 0; i < feature.length; i++) { for (let i = 0; i < points.length; i++) {
const x = feature[i].x; const x = points[i].x;
const y = feature[i].y; const y = points[i].y;
vertex(x, y) vertex(x, y)
} }
if (closed === true) { if(typeof closed === 'undefined') {
endShape(CLOSE); closed = CLOSE;
} else {
endShape();
} }
endShape(closed)
} }
// /** function drawPoints(points, radius) {
// * Wrapper around p5.js color class if(typeof radius === 'undefined') {
// * @param {*} c color, either as array, or string (css name or HEX string) radius = 2;
// */ }
// function getColor(c) {
// if(!Array.isArray(c)) c = [c];
// return new p5.Color(p5.instance, c);
// }
// var colors = { for (let i = 0; i < points.length; i++) {
// red: getColor('red'), const x = points[i].x;
// blue: getColor('blue'), const y = points[i].y;
// green: getColor('green'), circle(x, y, radius);
// }; }
}
function faceDistance(face1, face2){ function faceDistance(face1, face2){
// distance between faces, in pixels, not meters.. for now // distance between faces, in pixels, not meters.. for now