xxxxxxxxxx
33
let classifier;
let video;
function preload() {
classifier = ml5.imageClassifier('https://teachablemachine.withgoogle.com/models/45u3zAyqK/model.json', () => {
console.log('model loaded');
});
video = createCapture(VIDEO)
video.hide();
}
function setup() {
createCanvas(400, 400);
// frameRate(1);
textSize(36);
fill(255);
}
function draw() {
image(video, 0, 0);
let results = classifier.classify(video.get())
results.then(p => {
let choice = p[0];
if (choice.confidence > 0.95) {
text(choice.label, width/2, height-100);
}
// if (crunch)
});
}