Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

getting out of bounds exeption:0 dont know why

$
0
0

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(); } <


Viewing all articles
Browse latest Browse all 2896

Trending Articles