We are about to switch to a new forum software. Until then we have removed the registration on this forum.
this is the code
import processing.video.*;//importa la biblioteca de video
Capture cam1;
Capture cam2;
//Capture cam3;para agregar mas camaras
void setup() {
size(640, 480);
String[] cameras = Capture.list();
//if de seguridad
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]);
}
// The camera can be initialized directly using an
// element from the array returned by list():
cam1 = new Capture(this, cameras[14]);
cam2 = new Capture(this, cameras[1]);
//metodo para comenzar las camaras
cam1.start();
cam2.start();
//carga de pixeles y pixeles de las camaras
loadPixels();
cam1.loadPixels();
cam2.loadPixels();
}
void draw() {
if (cam1.available() == true) {
cam1.read();
}
if (cam2.available() == true) {
cam2.read();
}
//recorrer los pixeles de las camaras
for (int y = 0; y<height; y++)
{
for (int x = 0; x<width; x++)
{
int loc = x+y*width;
//color pixelactual = pixels[loc];
float treshold = mouseX;
color fondo = color(0,0,0);
float bright1 = brightness(cam1.pixels[loc]);
float bright2 = brightness(cam2.pixels[loc]);
if(bright1>treshold)
{
pixels[loc]=fondo;
}
}
}
updatePixels();
}
Answers
how do i put the code to look good?
Edit post, highlight code, press Ctrl-o.
This, and the possible answer to your question, is in the FAQ in the list on the left there...
I've deleted your two failed attempts at formatting and edited the original post.
Now, which line is reporting the error?
Please continue here: https://forum.processing.org/two/discussion/23565/how-can-i-use-multiple-webcams#latest
@koogs close please or mark as duplicated.
@sincos Let's keep similar questions under the same post. Avoid creating duplicated post as this just creates confusion.
Kf