xxxxxxxxxx
33
let video;
let myBodypix;
let segment;
function setup() {
createCanvas(640, 480);
video = createCapture(VIDEO);
video.size(width, height);
video.hide();
myBodypix = ml5.bodyPix(video, modelReady);
}
function modelReady () {
console.log('model is ready');
myBodypix.segmentWithParts({}, gotResults)
}
function gotResults(err, results) {
if (err) console.log(err)
if (results) {
// console.log('results: ', results);
segment = results.image;
image(video, 0, 0, width, height);
tint(255, 127);
image(segment, 0, 0, width, height);
myBodypix.segmentWithParts({}, gotResults)
}
}
// function draw() {
// image(video, 0, 0, width, height);
// image(segment, 0, 0, width, height)
// }