You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear community,
I have been inspired by Shiffman's videos about Image Classification and Video Classification. Consequently, I tried to combine working with video and with images. I tried to take a snapshot from the webcam and submit this snapshot for classification. The code is below. Unfortunately, I get an error (see screenshot).
I am not sure whether this is an issue or a mistake on my side.
Many thanks for your help and for the great library!
Hanna
Code:
let video;
let label = '';
let captureBtn;
let useButton;
let currentImg;
let retake = true;
function classify() {
mobilenet.predict(currentImg, gotResults);
}
function modelReady() {
console.log('Model is raedy!!!');
}
function gotResults(error, results) {
if (error) {
console.error(error);
} else {
console.log(results);
label = results[0].className;
let prob = results[0].probability;
}
}
function takesnap() {
currentImg = video.get();
if (retake) {
captureBtn.html('retake');
useBtn.show();
}
else {
captureBtn.html('snap!');
useBtn.hide();
}
retake = !retake;
}
function setup() {
createCanvas(320, 240);
video = createCapture(VIDEO);
video.size(320, 240);
video.hide();
currentImg = createImage(320,240);
mobilenet = ml5.imageClassifier('MobileNet', modelReady);
background(0);
captureBtn = createButton('Snap');
captureBtn.mousePressed(takesnap);
useBtn = createButton('Use this picture');
useBtn.mousePressed(classify);
useBtn.hide();
}
function draw() {
if (retake) {
var frame = video.get();
image(frame,0,0);
}
}
The text was updated successfully, but these errors were encountered:
Dear community,
I have been inspired by Shiffman's videos about Image Classification and Video Classification. Consequently, I tried to combine working with video and with images. I tried to take a snapshot from the webcam and submit this snapshot for classification. The code is below. Unfortunately, I get an error (see screenshot).
I am not sure whether this is an issue or a mistake on my side.
Many thanks for your help and for the great library!
Hanna
Code:
The text was updated successfully, but these errors were encountered: