shiffman / libfreenect

Just working on Processing library here
http://www.shiffman.net
122 stars 55 forks source link

NullPointerExeption issue - Kinect model 1473? #23

Open lineacurva opened 11 years ago

lineacurva commented 11 years ago

Hi,

I have a nullpointerexeption with any of the examples, e.g. AveragePointTracking.

The line which gives me the error is:

kinect.enableDepth(true);

This is the exception:

Exception in thread "Animation Thread" java.lang.NullPointerException at org.openkinect.processing.Kinect.enableDepth(Kinect.java:84) at AveragePointTracking$KinectTracker.(AveragePointTracking.java:108) at AveragePointTracking.setup(AveragePointTracking.java:37) at processing.core.PApplet.handleDraw(PApplet.java:2241) at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:243) at processing.core.PApplet.run(PApplet.java:2140) at java.lang.Thread.run(Thread.java:680)

I have this error both with Processing 2.08b and 1.5.1. on OSX Snow Leopard 10.6.8. My Kinect sensor is Xbox360 1473 model.

I wonder if anybody has this problem with this sensor, assuming everything is working with 1414 model.

Any fix/hint for this?

adiviness commented 11 years ago

I'm having the same sort of issue, my sensor is model 1517.

n312 commented 10 years ago

I am encountering issues with Kinect model 1473. I am running Processing 2.0.3 on OSX 10.8.2. I have read a number of fora and am aware that the issue may be with the model 1473. I need to work with that model and am hoping to get some help here.

When I run RGBDepthTest, I get NullPointerException error at kinect.enableDepth(depth). The console read, No Kinect devices found.

With this TSPS (Toolkit for Sensing People in Spaces), I can at least see that Kinect is connected.

I would very much appreciate any assistance. Thank you.

JamesHagerman commented 10 years ago

I'm also having this issue.

After compiling the libfreenect driver from the latest source (0.2.0) I was able to get the glview test app to run and it found the kinect...

But this shiffman processing library isn't working with it.

This is the start of the stack trace and the error is spits out after the first stack trace is printed out:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at org.openkinect.processing.Kinect.enableDepth(Kinect.java:82) ... Already called beginDraw()

So, there's something wrong with the library. The driver seems to work okay. I'm running OS X 10.8.3 and a new, out of the box 1473 Kinect.

I'll see if I can do any debugging but my java and processing library knowledge is pretty low so any help would be wonderful...

JamesHagerman commented 10 years ago

Well, crap. The head of libfreenect has diverged quite a bit from this fork of the code.

I can't even compile this library as it is now in this fork. I'm not sure what the dependencies are for the build and I can't find any instructions on how to set up the environment. Just modifying build.sh and running it is spitting out a bunch of errors when it tries to compile OpenKinectJNI/org_openkinect_Context.cpp

So I can't even start trying to figure out how to update this library so it will work with 1473.

@shiffman What are the environment requirements to build this library from the source?

JamesHagerman commented 10 years ago

Okay. I was able to build the Java portion of the code (I had to get jna.jar installed on my machine and in the classpath) but the C++ files are calling functions that have been heavily refactored in the libfreenect driver.

Getting this library to user a newer version of the driver (to support the 1473 device) is beyond me right now. I don't understand the code well enough.

shiffman commented 10 years ago

Thanks for the comments. I'm aware of the horrible out-of-date-ness of this library. I have it on my list to get to updating it but I just haven't had the time and am also struggling with motivation given the new kinect mac-incompatibility. I originally built the library using JNI and some xcode magic that I can barely remember. If anyone has the time to help I would be thrilled.

JamesHagerman commented 10 years ago

@shiffman: I've been working towards trying to merge your existing processing code with the latest HEAD of libfreenect. Since my last post, I finally got the .so and .jar to compile okay (I had to update some function names and variables in the .cpp and .h files)... but I don't know how to compile the actual library itself.

The build.sh script builds the .so/.jnilib along with the code in wrappers/java/OpenKinect... but that directory doesn't include the processing directory... which is the actual processing library itself as far as I can tell.

As far as I can tell, the library is an Eclipse project inside of wrappers/java/processing/KinectProcessing/ but I can't figure out how to compile it inside of Eclipse.

Honestly, I've never written a processing library and my java understanding is pretty minimal... but I've got a project that needs a working processing library for the new kinect so I'm pretty motivated to get this working.

JamesHagerman commented 10 years ago

Also, it would be pretty awesome if this library could (at some point) be pulled in to the main libfreenect repo...

JamesHagerman commented 10 years ago

Well, I'm getting closer. I modified some of the the code and moved some files around and was able to get the code to compile...

So I've been able to compile a version of the library that can at least connect to the 1473 Kinect with libfreenect at version (0.2.0)... but the library throws this error after just a few seconds of it running:

"Invalid memory access of location 0x0 rip=0x7fff8946f9fb"

So there's still something wrong... but at least I can start taking a look at the code now.

Also, I could only get it to work if processing is opening the sketches as 64 bit. This may be because of the way I'm compiling though. It also might be the reason why it crashes.

I'll try to put a fork together that has this work in it. It's still going to take a good amount of work to get stable...

JamesHagerman commented 10 years ago

Okay. It's pretty messy, but I forked this repo, added my modifications to the Processing library, and updated the libfreenect driver code to the projects current HEAD.

https://github.com/JamesHagerman/libfreenect

The driver should build (git clone ; cd libfreenect; mkdir build; cd build; cmake ..; make; sudo make install;)

The build.sh script will build the library itself but you need to modify it to set the path for core.jar and jna-4.0.0.jar otherwise it won't compile.

Also, the built files are named incorrectly. They need to be renamed before they will work in processing:

Freenect.jar -> openkinect.jar libOpenKinect.so -> libkinect.jnilib

Once they've been renamed, they should replace the originals in the Processing/libraries/openkinect/library directory.

The older Kinect should work with no issues. The new Kinect (1473) will work too... but crashes after a few seconds. I'm still looking in to why... I can't tell if it's a driver or library issue.

JamesHagerman commented 10 years ago

Oh, and the build.sh script puts the built files in wrappers/java_processing/dist/

shiffman commented 10 years ago

Did you ever get any further with this? @galsasson and I have been talking about updating the library to work with kinect 1473. This work may happen in early 2014.

JamesHagerman commented 10 years ago

I haven't had time to really get into the code any deeper then may last few posts.

I did add some comments to the build.sh script in my own fork of your code but that's about it.

Honestly, at this point, it might be easier to create a Processing wrapper using the existing upstream Java wrapper... Though I don't know how complete that code is either.

In any case, trying to get this stuff pulled back into the upstream Freenect repo would be helpful...

shiffman commented 10 years ago

This library is moving to a different repo and I'll be tracking future issues there. Hope to update for 1473 soon.

https://github.com/shiffman/OpenKinect-for-Processing