Loading...
Logo
Processing Forum
Kinect depth image is null for me when the renderer is OPENGL.  

The following code works fine for me...

import SimpleOpenNI.*;
SimpleOpenNI  kinect;
void setup() {
  kinect = new SimpleOpenNI(this);   
  kinect.enableDepth(); 
  size(640,480);   
}
void draw() {
  kinect.update();
  image(kinect.depthImage(),0,0);
}

But by simply importing processing.opengl.* and changing renderer to OPENGL, i.e. size(640,480,OPENGL), the program crashes on first draw because kinect.depthImage() is null, with the following error.

SimpleOpenNI Version 0.24
Exception in thread "Animation Thread" java.lang.NullPointerException
at SimpleOpenNI.SimpleOpenNI.updateDepthImage(SimpleOpenNI.java:800)
at SimpleOpenNI.SimpleOpenNI.depthImage(SimpleOpenNI.java:402)
at KinectDepthImage.draw(KinectDepthImage.java:55)
at processing.core.PApplet.handleDraw(PApplet.java:1631)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)

Does anyone know what the issue is?  I am on OSX Lion with Processing 1.5.1, SimpleOpenNI version 0.24.

Replies(3)

Fixed it!  Simply need to declare OPENGL before instantiating the Kinect, so moved the size statement to first within setup.

However, the frameRate associated with the image command (image(kinect.depthMap()) suddenly becomes about 4x slower in OPENGL mode, and quickly throws this error.  Are you not supposed to use image function in OPENGL?

java(5131,0xbaa03000) malloc: *** mmap(size=524288) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Invalid memory access of location 0x5af00 eip=0xbb3403ff

The code now is:


import SimpleOpenNI.*;
import processing.opengl.*;

SimpleOpenNI kinect;

void setup()
{
  size(1400,900, OPENGL); 
  kinect = new SimpleOpenNI(this);
  kinect.enableDepth();
}

void draw()
{
  kinect.update();
  image(kinect.depthImage(),0,0);
}

hey i have the same issue but atleast your solution is letting it take opengl!!
i wonder what can be done to make it work in proper frame rate
I've seen this same problem, for me I see that invalid memory error sometimes, and other times is just runs out of memory (both scenarios happen soon after the sketch starts).  If I watch the activity monitor when I start the sketch the memory usage climbs at almost 500 MB per second!  Looks like there's some kind of serious memory leak when using opengl...