I’m trying to follow “coding train’s” example of capturing images from a webcam for a “photo booth”.
It was working great up until I go to the for loop to capture the images.
When I use “get()” on the createCapture() object, it returns an image with no pixels in it. (I tested this but removed that code).
What am I doing wrong? Or is there an easier way to do this?
I’m writing a lesson for students on how to create a greenscreen from a webcam and fill the background.
let video;
let pics = [];
var button;
var snapped;
var idx = 0;
function setup() {
createCanvas(160,120);
//snapped = createCanvas(160, 120);
//snapped.background(0);
background(255);
video = createCapture(VIDEO);
video.size(160,120);
button = createButton('shoot pic');
button.mousePressed(shoot);
}
function shoot() {
let img = video.get(0,0,160,120);
pics.push(img);
}
function draw() {
//image(snapped, 0, 0);
for(var i = 0; i < pics.length; i++) {
image(pics[i], 0, 0);
}
}