I’m trying to draw video from the webcam on a canvas:
function update() {
draw.clear();
draw.image(camera.get(), 0, 0);
}
var s = function(sketch) {
sketch.setup = function() {
sketch.createCanvas(640, 480);
camera = draw.createCapture('video');
camera.hide();
updateInterval = setInterval(update, 1000 / 24);
}
}
var draw = new p5(s);
When camera.hide()
is removed, one can see that the <video>
element created is playing live webcam video, but the canvas is frozen on one frame and doesn’t actually play. I’ve tried the examples on the p5.js docs for createCapture
, but those examples don’t suffer from the same problem and the video plays there.
Why is this?
Thanks in advance!