xxxxxxxxxx
44
let video;
let handPose;
let hands;
let colors;
function modelReady() {
console.log("ready ");
background(100);
handpose.on('predict', results => {
hands = results;
});
}
function setup() {
createCanvas(640, 480);
video = createCapture(VIDEO);
const options = {
detectionConfidence: 0.4, // Threshold for discarding a prediction. Defaults to 0.8.
scoreThreshold: 0.75, // A threshold for removing multiple (likely duplicate) detections based on a "non-maximum suppression" algorithm. Defaults to 0.75
iouThreshold: 0.3, // A float representing the threshold for deciding whether boxes overlap too much in non-maximum suppression. Must be between [0, 1]. Defaults to 0.3.
}
handpose = ml5.handpose(video, options, modelReady);
video.hide();
}
function draw() {
background(0);
//if(hands)
//console.log(hands);
if (hands && hands.length > 0) {
hand = hands[0];
let annotations = hand.annotations;
let parts = Object.keys(annotations);
for (let part of parts) {
for (let position of annotations[part]) {
let [x, y, z] = position;
ellipse(x, y, 16)
}
}
}
}