xxxxxxxxxx
let sora;
let video;
let handpose;
let hands;
// Font laden
function preload() {
sora = loadFont('Sora-SemiBold.ttf');
}
function setup() {
createCanvas(640, 480);
video = createCapture(VIDEO);
video.size(640, 480);
video.hide();
handpose = ml5.handpose(video, modelLoaded);
textFont(sora);
}
function draw() {
background(150, 100);
//tint(112, 100, 150);
image(video, 0, 0);
if (hands && hands.length > 0) {
text(hands.length, 20, 20);
fill(255, 20, 147, );
stroke(500);
textSize(130);
textAlign(CENTER, BOTTOM);
// Finger tips: 4, 8, 12, 16, 20
//text("N", hands[0].landmarks[20][0], hands[0].landmarks[20][1]);
//text("O", hands[0].landmarks[16][0], hands[0].landmarks[16][1]);
text(".", hands[0].landmarks[12][0], hands[0].landmarks[12][1]);
//text("E", hands[0].landmarks[8][0], hands[0].landmarks[8][1]);
//text("~", hands[0].landmarks[4][0], hands[0].landmarks[4][1]);
}
}
// When the model is loaded
function modelLoaded() {
console.log('Handpose loaded!');
handpose.on('predict', gotHands);
}
// Listen to new 'predict' events
function gotHands(results) {
hands = results;
}
// Listen to new 'predict' events
handpose.on('predict', results => {
predictions = results;
});