p5(sketch => {
let mobileNet
let video
function onModelReady() {
mobileNet.predict(onPrediction)
}
function onPrediction(error, results) {
if (error) mutable output = [error]
else mutable output = results
onModelReady()
}
sketch.setup = function() {
sketch.createCanvas(640, 480)
sketch.background(0)
video = sketch.createCapture(sketch.VIDEO)
video.hide()
mobileNet = ml5.imageClassifier('MobileNet', video, onModelReady)
};
sketch.draw = function() {
sketch.image(video, 0, 0)
}
})