xxxxxxxxxx
36
let handPose;
let video;
let hands = [];
function preload() {
handPose = ml5.handPose();
}
function setup() {
createCanvas(640, 480);
video = createCapture(VIDEO);
video.size(640, 480);
video.hide();
handPose.detectStart(video, gotHands);
}
function gotHands(results) {
hands = results;
}
function draw() {
image(video, 0, 0, width, height);
for (let i = 0; i < hands.length; i++) {
let hand = hands[i];
for (let j = 0; j < hand.keypoints.length; j++) {
let keypoint = hand.keypoints[j];
fill(0, 255, 0);
noStroke();
circle(keypoint.x, keypoint.y, 10);
}
}
}