xxxxxxxxxx
let video;
let poseNet;
let poses = [];
let gif_bird;
let img_bird;
var bird;
function preload() {
bird = loadSound('eichelhaeher.mp3');
gif_bird = loadImage("schulter.gif");
img_bird = loadImage("Eichelhäher_crop.png");
}
function setup() {
bird.play();
createCanvas(640, 480);
video = createCapture(VIDEO);
video.size(640, 480);
video.hide();
poseNet = ml5.poseNet(video, modelLoaded);
poseNet.on("pose", function(results) {
poses = results;
});
//gif_bird.play();
}
function draw() {
background(255);
//tint(100);
image(video, 320, 240);
// Draw all joints
drawKeypoints();
if (poses.length > 0) {
fill(255, 100);
stroke(255);
let pose = poses[0].pose;
ellipse(pose.leftShoulder.x, pose.leftShoulder.y - 10, 20, 20);
imageMode(CENTER);
image(gif_bird, pose.leftShoulder.x - 50, pose.leftShoulder.y + 230, 720, 1280);
image(img_bird, pose.rightShoulder.x, pose.rightShoulder.y - 80, 100, 100);
}
}
function mousePressed() {
}
function modelLoaded() {
print("Model Loaded");
}
// A function to draw ellipses over the detected keypoints
function drawKeypoints() {
// Loop through all the poses detected
for (let i = 0; i < poses.length; i += 1) {
// For each pose detected, loop through all the keypoints
const pose = poses[i].pose;
for (let j = 0; j < pose.keypoints.length; j += 1) {
// A keypoint is an object describing a body part (like rightArm or leftShoulder)
const keypoint = pose.keypoints[j];
// Only draw an ellipse is the pose probability is bigger than 0.2
if (keypoint.score > 0.2) {
noFill();
stroke(200);
ellipse(keypoint.position.x, keypoint.position.y, 5, 5);
}
}
}
}