Skip to content

Commit e56f40a

Browse files
committed
Fix additional loadeddata errors in CartoonGan and ObjectDetector
1 parent 11cf24f commit e56f40a

File tree

2 files changed

+10
-4
lines changed
  • examples/p5js

2 files changed

+10
-4
lines changed

examples/p5js/CartoonGAN/CartoonGan_WebCam/sketch.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ function preload() {
88

99
function setup() {
1010
createCanvas(320, 240);
11-
video = createCapture(VIDEO);
11+
video = createCapture(VIDEO, videoReady);
1212
video.size(320, 240);
13+
}
14+
15+
function videoReady() {
1316
cartoonGAN.generate(video, gotResults);
1417
}
1518

examples/p5js/ObjectDetector/ObjectDetector_COCOSSD_Video/sketch.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ let detections = [];
1515

1616
function setup() {
1717
createCanvas(640, 480);
18-
video = createCapture(VIDEO);
18+
video = createCapture(VIDEO, videoReady);
1919
video.size(640, 480);
2020
video.hide();
21+
}
22+
23+
function videoReady() {
2124
// Models available are 'cocossd', 'yolo'
2225
detector = ml5.objectDetector('cocossd', modelReady);
2326
}
@@ -37,8 +40,8 @@ function modelReady() {
3740
function draw() {
3841
image(video, 0, 0);
3942

40-
for (let i = 0; i < detections.length; i++) {
41-
let object = detections[i];
43+
for (let i = 0; i < detections.length; i += 1) {
44+
const object = detections[i];
4245
stroke(0, 255, 0);
4346
strokeWeight(4);
4447
noFill();

0 commit comments

Comments
 (0)