xxxxxxxxxx
43
let classifier;
let video;
let guess="not loaded";
function preload()
{
classifier=ml5.imageClassifier("MobileNet", loadComplete);
classifier.classify(video, showResults);
}
function showResults(result)
{
//console.log(result);
guess=result[0].label;
}
function loadComplete()
{
console.log("Classifier Loaded!");
}
function setup() {
createCanvas(300, 400);
video=createCapture(VIDEO)
video.hide();
classifier.classifyStart(video, showResults);
}
function draw() {
background(220);
image(video, 0,0, width, height);
fill('black');
rect(0, height-50, width, 50);
stroke('white');
fill('white');
text(guess, 20, height-25);
}