こんにちは。いつもありがとうございます。
Javaは全くの初心者でよくわからないのですが、下のコードのdraw関数内の
prevColor[i]で、ArrayIndexOutOfBoundsException: 76800というエラーが出ます。配列の長さ以上をループしようとしているのかと思いましたが、何かよくわからず。。。
分かる方おられましたらご教授ください。宜しくお願いします。
Java
1import org.openkinect.freenect.*; 2import org.openkinect.processing.*; 3 4// The kinect stuff is happening in another class 5//KinectTracker tracker; 6Kinect kinect; 7 8//ArrayList<ParticleSystem> particleArray; 9PVector previousMousePos; 10int frameRateSet = 60; 11//float[] colorChange = new float[2]; 12float[] counter = new float[2]; 13float[] colorMap = new float[2]; 14int step = 4; 15int[] depth; 16PImage depthImage; 17float kinectColorMap; 18float[] prevColor = new float[307200/step]; 19 20void setup(){ 21 size(640,480); 22 kinect = new Kinect(this); 23 kinect.initDepth(); 24 depthImage = kinect.getDepthImage(); 25} 26 27void draw(){ 28 29 depth = kinect.getRawDepth(); 30 //depthImage = kinect.getRawDepth(); 31 //image(depthImage,0,0); 32 33 fill(255); 34 for(int i = 0; i < depth.length; i+= step){ 35 //pushMatrix(); 36 boolean colorCheck = false; 37 noStroke(); 38 // kinect v1, the raw depth values range between 0 and 2048 39 kinectColorMap = map(depth[i],0,2048,0,255); 40 if(kinectColorMap < 100){ 41 colorCheck = true; 42 fill(0); 43 }else{ 44 fill(255); 45 colorCheck = false; 46 } 47 48 if(prevColor != null && prevColor[i] != kinectColorMap){ 49 ellipse((float)i%kinect.width, 50 (float)Math.floor(i/kinect.width), 51 10,10); 52 println("working"); 53 } 54 55 noStroke(); 56 rect( 57 (float)i%kinect.width, 58 (float)Math.floor(i/kinect.width), 59 (float)step, 60 (float)step 61 ); 62 println(prevColor[i],kinectColorMap); 63 64 65 66 //popMatrix(); 67 }//end loop 68 69} 70 71void mousePressed(){ 72}
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。