From 744794c05ae7faf13641316d9f55529466450bb8 Mon Sep 17 00:00:00 2001 From: Yi-Chun Lan Date: Thu, 2 Nov 2023 18:02:04 -0400 Subject: [PATCH] Update sketch.js Error message: Uncaught TypeError: Cannot read properties of undefined (reading 'segment') at HTMLVideoElement.videoReady (sketch.js:30:11) videoReady @ sketch.js:30 ========= Change the order to load the ml5 first, then get the video. So it works now~ --- examples/javascript/BodyPix/BodyPix_Webcam/sketch.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/javascript/BodyPix/BodyPix_Webcam/sketch.js b/examples/javascript/BodyPix/BodyPix_Webcam/sketch.js index be85ac648..c5d789854 100644 --- a/examples/javascript/BodyPix/BodyPix_Webcam/sketch.js +++ b/examples/javascript/BodyPix/BodyPix_Webcam/sketch.js @@ -14,10 +14,11 @@ async function setup() { // create a canvas to draw to canvas = createCanvas(width, height); ctx = canvas.getContext('2d'); - // get the video - video = await getVideo(); // load bodyPix with video bodypix = await ml5.bodyPix(options) + // get the video + video = await getVideo(); + } // when the dom is loaded, call make(); @@ -86,4 +87,4 @@ function createCanvas(w, h){ canvas.height = h; document.body.appendChild(canvas); return canvas; -} \ No newline at end of file +}