// the link to your model provided by Teachable Machine export panel
const URL = "./model/";
+ const sideLength = 200;
+ let isStop = true;
+ let isInitiated = false;
let model, webcam, labelContainer, maxPredictions;
+ const stop = () => {
+ isStop = true;
+ document.getElementById('stop').style.display = 'none';
+ document.getElementById('start').style.display = 'block';
+ }
+
+ async function start() {
+ isStop = false;
+ document.getElementById('start').style.display = 'none';
+ document.getElementById('stop').style.display = 'block';
+ if (!isInitiated) {
+ console.log(isInitiated)
+ await init();
+ isInitiated = true;
+ }
+
+ window.requestAnimationFrame(loop);
+ }
+
// Load the image model and setup the webcam
async function init() {
@@ -38,10 +61,9 @@
Gesture Genius: ASL AI Recognition
// Convenience function to setup a webcam
const flip = true; // whether to flip the webcam
- webcam = new tmImage.Webcam(200, 200, flip); // width, height, flip
+ webcam = new tmImage.Webcam(sideLength, sideLength, flip); // width, height, flip
await webcam.setup(); // request access to the webcam
await webcam.play();
- window.requestAnimationFrame(loop);
// append elements to the DOM
document.getElementById("webcam-container").appendChild(webcam.canvas);
@@ -54,8 +76,9 @@