Preformatted text
`Hello,
I need to analyse a grayscale image from webcam.
I know that **filter(GRAY)** would do it for the display... but i also need to transform all the pixels.
Could anyone tell me what is the best way for this ? the faster way ?
Thank you for your help.
import processing.video.*;
Capture cam;
void setup() {
size(500, 400, P3D);
String[] cameras = Capture.list();
if (cameras.length == 0)
{
println("There are no cameras available for capture.");
exit();
} else
{
println("Available cameras:");
for (int i = 0; i < cameras.length; i++)
{
println(cameras[i]);
}
cam = new Capture(this, 200, 200, cameras[0]);//0
cam.start();
}
}
void captureEvent(Capture video) {
video.read();
}
void draw() {
textureMode(NORMAL);
image(cam, 0, 0, 100, 100);
filter(GRAY);
//how to Split the original webcam image onto 4 vidéos on screen
/////////////
////A - B////
////D - C////
/////////////
//shape A
beginShape();
texture(cam);
vertex(100, 0, 0, 0, 0);
vertex(300, 0, 0, 0.5, 0);
vertex(300, 200, 0, 0.5, 0.5);
vertex(100, 200, 0, 0, 0.5);
endShape();
//tester les superpositions vidéos avec couche alpha
//shape B
beginShape();
texture(cam);
vertex(300, 0, 0, 0.5, 0);
vertex(500, 0, 0, 1, 0);
vertex(500, 200, 0, 1, 0.5);
vertex(300, 200, 0, 0.5, 0.5);
endShape();
//shape C
beginShape();
texture(cam);
vertex(300, 200, 0, 0.5, 0.5);
vertex(500, 200, 0, 1, 0.5);
vertex(500, 400, 0, 1, 1);
vertex(300, 400, 0, 0.5, 1);
endShape();
//shape D
beginShape();
texture(cam);
vertex(100, 200, 0, 0, 0.5);
vertex(300, 200, 0, 0.5, 0.5);
vertex(300, 400, 0, 0.5, 1);
vertex(100, 400, 0, 0, 1);
endShape();
//
}