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(0);
tint(100);
image(video, 0, 0);
if (hands && hands.length > 0) {
fill(255, 100);
stroke(255);
// Finger tips: 4, 8, 12, 16, 20
for (let i = 0; i < hands[0].landmarks.length; i++) {
text(i, hands[0].landmarks[i][0], hands[0].landmarks[i][1]);
ellipse(hands[0].landmarks[i][0], hands[0].landmarks[i][1], 10, 10);
}
}
}
// 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;
});