<does video.size() function doesn’t work properly for pixel manipulation.
the moment i am using it I am getting a black screen in the canvas though the video is running in the browser
I am sending the code:
let video;
function setup() {
createCanvas(320, 240);
video=createCapture(VIDEO);
pixelDensity(1);
video.size(320,240);
}
function draw() {
background(220);
loadPixels();
video.loadPixels();
for(var y=0;y<height;y++){
for(var x=0;x<width;x++){
let index=(x+y*width)*4;
var r=video.pixels[index+0];
var g=video.pixels[index+1];
var b=video.pixels[index+2];
var a=255;
let br=(r+g+b)/3;
pixels[index+0]=br;
pixels[index+1]=br;
pixels[index+2]=br;
pixels[index+3]=255;
}
}
updatePixels();
}
please suggest what is wrong
/>