Skip to content

Commit 8864cb5

Browse files
committed
update video file example to work with a fixed sized video 640 x 480
1 parent cdaa7c7 commit 8864cb5

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

examples/objectDetection-video/sketch.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,26 @@ function gotDetections(results) {
2121
}
2222

2323
function setup() {
24-
// Create canvas with initial size - will be resized later
2524
createCanvas(640, 480);
2625

2726
// Load and loop the video for object detection
28-
video = createVideo('test.mov');
29-
video.size(width, height);
27+
video = createVideo('test.mp4'); // video sized 640 x 480
3028
video.hide();
3129
video.loop();
3230

3331
detector.detectStart(video, gotDetections);
3432
}
3533

3634
function draw(){
37-
image(video, 0, 0, width, height); // draw video frame
38-
39-
// Scale factors from original video to canvas size
40-
let scaleX = width / video.elt.videoWidth;
41-
let scaleY = height / video.elt.videoHeight;
35+
image(video, 0, 0); // draw video frame
4236

4337
for (let i = 0; i < detections.length; i++) {
4438
let detection = detections[i];
4539

46-
let x = detection.x * scaleX;
47-
let y = detection.y * scaleY;
48-
let w = detection.width * scaleX;
49-
let h = detection.height * scaleY;
40+
let x = detection.x;
41+
let y = detection.y;
42+
let w = detection.width;
43+
let h = detection.height;
5044

5145
stroke(0, 255, 0);
5246
strokeWeight(4);
-16.9 MB
Binary file not shown.
5.11 MB
Binary file not shown.

0 commit comments

Comments
 (0)