Friday, January 24, 2014

Processing and FreeNect on Ubuntu 12 64bit

I recently acquired a Kinect sensor with the intention of using it for 3D scanning of things for printing on our TVRR printer. But it seems there is a lot more I can use it for. Robots, midi and more are now on my project list.

I've got it working on various OS's  including Win7 and Xbuntu 32bit and Lubuntu 64bit. There seems to be lots of choices of software, but much stems from around 2010 and has ownership and development seems to to have alot since then.

I am obviously rather late to the Kinect game and this means I have to pick the right bones out of a pile of skelebones,

I plan to records notes here to help others that may come across the same problems.


Today I got Processing working on my Lubuntu 64bit system and able to run the Freenect examples. An option is to use OpenNI instead of Freenect, but I had Freenect installed and working already and I understand they are not compatible with each other.

I found instructions at http://www.local-guru.net/blog/2010/12/28/how-to-use-the-libfreenect-processing-wrapper-on-ubuntu the differences being my 64bit OS and my use of OpenJDK 7 (needed for PraxisLive - but that is another story) So my Paths were different and I did not remove the -m64 directive.

It compiled okay but I got an error:
java: symbol lookup error: /home/../sketchbook/libraries/openkinect/library/libOpenKinect.so: undefined symbol: libusb_init

There are several forum posts reporting this error, but no good answers. I initially thought it may be a PATH error so I double checked the paths in build.sh, I added a symbolic link in the /usr/lib/jvm/ directory for JDK 7 to mirror the one for JDK 6, but this did not help.

I found this post: http://fightpc.blogspot.co.uk/2011/05/use-processing-and-kinect-in-ubuntu.htm and in the comments found this http://fightpc.blogspot.co.uk/2011/05/use-processing-and-kinect-in-ubuntu.html#c3034086444552109525
reporting the same problem. As the main post + mentions an update advising he has 64bit Ubuntu running okay, I am encouraged to pursue a solution. The post is from May 2011 though.

and I see this reply that matched my googling:
http://fightpc.blogspot.co.uk/2011/05/use-processing-and-kinect-in-ubuntu.html#c2174108083274595404
saying: I'm assuming you have libusb-1.0 already installed in your system. The complaint is about not being able to find libusb init code. 


So I'm still not working. The reference to having libusb-1.0 installed (which I have) got my googling libusb and without reference to kinect or freenect.

This pulled up the post: http://libusb.6.n5.nabble.com/Compile-in-GCC-td7048.html from 2009 which holds a query about a problem 'Roman' was having with gcc and libusb and getting the same error.

Tim Roberts reply was:
You told it where to find the include files, but not the name of the 
library.  If the library is in your /usr/local/lib directory, try adding 
-lusb-1.0 to your command line. 

I tried this and Viola! my example loading in Processing and reported it couldn't find the Sensor. I plugged the Kinect in and a window popped up, but no images.

I ran 'freenect-glview' to check this was still working, which it was, and reran the Processing sketch, and double viola! the images came up.

A simple solution but a pig to find even with all the help of google.