如何在Processing中调试“ArrayIndexOutOfBoundsException:0”

时间:2016-04-19 20:43:27

标签: processing

我正在尝试让Kim Asendorf的像素排序代码与处理中的网络摄像头的输入一起工作。

我收到错误:“ArrayIndexOutOfBoundsException:0”。关于如何解决这个问题的任何想法?

//BLACK
int getFirstNotBlackY(int _x, int _y) {
int x = _x;
int y = _y;
color c;
if (y < height) {
while ( (c = cam.pixels[x + y * cam.width]) < blackValue) {
  y++;
  if (y >= height) return -1;
}




import processing.video.*;

Capture cam; 

String[] cameras = Capture.list();

int mode = 0;

//MODE:
//0 -> black
//1 -> bright
//2 -> white
//b(16777216)


int loops = 1;

int blackValue = -10000000;
int brigthnessValue = 60;
int whiteValue = -6000000;

int row = 0;
int column =

boolean saved = false;

void setup() {
  size(640, 480);

  import processing.video.*;

  String[] cameras = Capture.list();

  import processing.video.*;

  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():
    cam = new Capture(this, cameras[0]);
    cam.start();
  }
 }

我添加了用于初始化网络摄像头的代码。

0 个答案:

没有答案