Fighting with computers

Computers are not always friendly.

Tuesday, May 24, 2011

Use Processing and Kinect in Ubuntu

I'm working on a project that uses Kinect depth camera to detect a person silhouette as I have mentioned before in this blog.

Part of the development was done using a Mac because I found a library that enabled me to use Kinect directly from Processing (which I've found very convenient for prototyping).

It did not hurt that an OpenCV library for processing was also available.

What was missing was a version of the Kinect's Processing library to be used with GNU/Linux. Fortunately, someone took the time to tweak the Mac version to make it work and to post the process online. It did not work for me exactly as it was but it was close. So just in case you want to experience with it, here are the steps that worked for me:

  1. Get a copy of the library:
    git clone git://github.com/shiffman/libfreenect.git
  2. Create a and move to a build directory inside libfreenect folder
    cd libfreenect
    
    mkdir build
    
    cd build
    
    cmake ..
    
    make 
    
    sudo make install
  3. Go to wrappers/java and edit build.sh file (remove -m64 compiler flag unless your platform is 64-bits)
  4. Make sure the folders for libfreenect.a file and for the Java directory containing jni.h are correct in the build.sh file
  5. Run build.sh:
    sh build.sh
  6. Make sure the step above was error free.
  7. Now copy the folder openkinect from wrappers/java/processing/distribution to your sketchbook/libraries folder
  8. Copy file libOpenKinect.so from wrappers/java/dist to sketchbook/libraries/openkinect/library/
  9. Almost there, create a symbolic link in that last folder:
    ln -s libOpenKinect.so libkinect.so
  10. Fire up Processing IDE and try any of the examples from the openkinect library once you have connected your Kinect to the USB port.
Update: In case of trouble do not forget all the install details provided here.If you're using Ubuntu 11.04, the following packages need to be installed: git-core, cmake, libusb-1.0, g++, libxmu-dev, bixi-dev, libglut3-dev. If it happens to be a 64bit Ubuntu it won't work (I'm still figuring out how to make it work).

Fixed! In case you have 64 bit ubuntu, make sure your processing folder does not include java binaries (if it does, it'll likely be 32 bit, as it was the case with my processing 1.5.1). Once you're using 64 bit java, the 64 bit library created with the instructions above will work nicely too.

Monday, May 09, 2011

Fixing a broken compact-flash socket (sort of)


A few days ago an incorrect manipulation of the compact flash memory broke my Canon reflex camera memory socket. It was a very bad moment as I was not able to use it in my recent trip to China.

Though I was able to get some thin tweezers I was only capable of breaking the bent pin. So my camera was useless now.

Once back home, I've tried a simple solution that worked nicely, so nicely I want to share it with you: I just took a strand of copper from an electric wire and I stuffed it in to the hole of the compact flash memory that corresponded to the broken pin. It created kind of a small copper wire brush that makes contact with the broken pin once the memory is inserted. It is a cheap solution to the problem that I've found surprisingly good.

If you have several broken pins you may try this, but I am not so confident you'll get a decent contact for all of them at the same time.