Java lang Index out of the bound Exception
in
Contributed Library Questions
•
15 days ago
Hi ,
It seems nothing is wrong in the code but somehow I am getting "
java.lang.IndexOutofBoundsException Index: 0,Size: 0 " error
Any suggestion
error log:
SimpleOpenNI Version 0.27
java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58)
at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:100)
at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:205)
at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172)
at javax.media.opengl.Threading.invoke(Threading.java:191)
at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:483)
at processing.opengl.PGL.requestDraw(PGL.java:1149)
at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1604)
at processing.core.PApplet.run(PApplet.java:2176)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at org.processing.wiki.triangulate.Triangulate.triangulate(Unknown Source)
at user_mesh.draw(user_mesh.java:55)
at processing.core.PApplet.handleDraw(PApplet.java:2305)
at processing.opengl.PGL$PGLListener.display(PGL.java:2601)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:588)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:572)
at javax.media.opengl.awt.GLCanvas$7.run(GLCanvas.java:1054)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1034)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:909)
at javax.media.opengl.awt.GLCanvas$8.run(GLCanvas.java:1065)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:666)
at java.awt.EventQueue.access$400(EventQueue.java:81)
at java.awt.EventQueue$2.run(EventQueue.java:627)
at java.awt.EventQueue$2.run(EventQueue.java:625)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:636)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
- import SimpleOpenNI.*;
- import org.processing.wiki.triangulate.*;
- ArrayList triangles = new ArrayList();
- ArrayList points = new ArrayList();
- SimpleOpenNI kinect;
- int userID;
- Boolean tracking=false;
- int[] userMap = null;
- void setup() {
- size(640, 480, P3D);
- kinect = new SimpleOpenNI(this);
- kinect.enableDepth();
- kinect.enableUser(SimpleOpenNI.SKEL_PROFILE_NONE);
- }
- void draw() {
- background(0);
- kinect.update();
- if (kinect.getNumberOfUsers()>0) {
- userMap = kinect.getUsersPixels(SimpleOpenNI.USERS_ALL); // find out which pixels have users in them// populate the pixels array
- } // from the sketch's current contents
- loadPixels();
- for (int x=0; x<width; x++) {
- for (int y=0; y<height; y++) {
- int index = x + y * width;
- if ( userMap!=null && userMap[index] > 0) {
- points.add(new PVector(x, y));
- pixels[index] = color(255, 0, 0);
- }
- }
- }
- // display the changed pixel array
- updatePixels();
- //-------------------------------
- triangles = Triangulate.triangulate(points);
- //-------------------------------
- stroke(0, 40);
- fill(255, 40);
- beginShape(TRIANGLES);
- for (int i = 0; i < triangles.size(); i++) {
- Triangle t = (Triangle)triangles.get(i);
- vertex(t.p1.x, t.p1.y);
- vertex(t.p2.x, t.p2.y);
- vertex(t.p3.x, t.p3.y);
- }
- endShape();
- //-------------------------------
- }
- void onNewUser(int uID) {
- userID = uID;
- tracking = true;
- println("tracking");
- }
1