xxxxxxxxxx
var capture, imageout;
function setup() {
createCanvas(windowWidth, windowHeight);
capture = createCapture(VIDEO); // this opens up the camera
pixelDensity(1); // turns off oversampling ("retina display")
capture.size(640, 480); // this is in pixels
capture.hide(); // telling the browser to hide the camera so we can draw it ourselves
imageout = createImage(640, 480); // create an empty picture
}
function draw() {
background(0);
// capture.loadPixels();
// for(let i = 0;i<capture.pixels.length;i+=4)
// {
// let L = (capture.pixels[i] + capture.pixels[i+1] + capture.pixels[i+2]) / 3;
// capture.pixels[i] = L;
// capture.pixels[i+1] = L;
// capture.pixels[i+2] = L;
// }
// capture.updatePixels();
capture.LoadPixels();
imageout.loadPixels();
for(let i = 0;i<imageout.pixels.length;i+=4)
{
imageout.pixels[i] = random(255);
imageout.pixels[i+1] = random(255);
imageout.pixels[i+2] = random(255);
imageout.pixels[i+3] = 255;
}
imageout.updatePixels();
image(imageout, 0, 0, width, height);
}