Processing + GSVideo + NyARToolkit on Linux x86_64

Every now and then, I blast out the cruft from my nerd gland’s exit duct by writing a terribly nerdy post.  This is just such a post, so if you don’t speak Nerd, i’d highly recommend that you go have some fun elsewhere, at least until my next Weekly Head Voices of course!

As mentioned around these parts, I’m currently playing with Processing, a beautiful programming stack for making interactive visual, err, thingies. To be more specific, I’d like to use processing together with something like ARToolkit to do real-time 3D tracking of markers in live video, for augmented reality fun.  To see what this could look like, see this YouTube video:

Today’s challenge is getting whole stack, including processing, the GSVideo video capture library for processing and the NyARToolkit augmented reality for processing going on Linux x86_64 (64bit).  On Linux x86 (32bit) this is much more straight-forward, but I wouldn’t write a blog post about straight-forward, now would I?

Here is the recipe:

  1. Make sure you have the native 64bit Sun JDK installed for your system.  On this Ubuntu 9.10 machine it’s sun-java6-jdk 6-15-1, on Ubuntu 10.04 (also tested) it’s 6.20dlj-1ubuntu3.
  2. Also install the jogl libraries, on this machine called libjogl-java.
  3. Make sure you have the whole of gstreamer installed. On ubuntu, all packages containing “gstreamer”.
  4. Get and unpack the processing for Linux tarball (I’ve tested this whole procedure with processing 1.0.9, 1.1 and 1.2.1) from the processing download site.
  5. In the unpacked processing directory, remove the whole java subdirectory. Now make a symlink pointing to your system java directory (the one containing bin, ext, jre, lib, etc.).  On my system, that was:
    cd processing
    rm -rf java
    ln -s /usr/lib/jvm/java-6-sun-1.6.0.15 java
    
  6. In processing/libraries/opengl/library remove the 3 libjogl*.so files and libgluegen-rt.so. Symlink their replacements from /usr/lib/jni with for example:
    cd processing/libraries/opengl/library
    rm lib*.so
    ln -s /usr/lib/jni/libgluegen-rt.so
    ln -s /usr/lib/jni/libjogl_awt.so
    ln -s /usr/lib/jni/libjogl.so
    
  7. Download and unpack gsvideo into processing/libraries.  You should be able to run the examples in processing/libraries/gsvideo/examples/Capture with the PDE (Processing Development Environment).
  8. Download and unpack the NyARToolkit for Processing library into processing/libraries.

You should now be able to run the NyARToolkit examples by changing replacing the import call as follows:

// replace this call:
// import processing.video.*;
// by this call:
import codeanticode.gsvideo.*;

and changing the Capture class (twice) to GSCapture and perhaps also the capture resolution, depending on your camera. The relevant conversions are:

// Capture cam;
// becomes:
GSCapture cam;

// later, in setup():
// cam=new Capture(this,width,height);
// becomes:
cam=new GSCapture(this,width,height);

The major trick in all of this is converting your Processing installation to use your system 64bit JDK instead of its own built-in 32bit JDK.

Let me know in the comments if this worked (or didn’t) for you!

19 thoughts on “Processing + GSVideo + NyARToolkit on Linux x86_64”

  1. Pingback: Charl Botha
  2. Pingback: Damian Garcia
  3. Pingback: Ben Bull
  4. Hey this worked great, except that I am having an issue with my camera. I am getting a ton of blue flickering. In SingleARTKMarkerTest at the beginning of the draw() method there is a check that says: if (cam.available() !=true) {
    return;
    }
    If I put a println(“not available”); it prints that out every time it flickers blue. So apparently my camera is not as responsive as.. GStreamer? NyARToolkit? would like. Do you have any ideas as to how to fix this?

    1. In my code, I make sure to only clear the display if the camera is available, else I skip back to the next cam.available(). When I it this way, I see no flickering, as the previous image is left undisturbed.

      I hope this helps.

    2. I removed the background(255); and adjusted my resolution and the flickering went away.

      Also instead of GSCapture I am using GSPipeline with v4l2 and it seems to have better results, with my camera anyway.

      size(640,480,OPENGL);
      cam = new GSPipeline(this, “v4l2src ! ffmpegcolorspace ! video/x-raw-rgb,width=640,height=480, bpp=32, depth=24”);

    1. On 32bit it’s much easier. Simply download and install processing, the download and install gsvideo and my modified nyartoolkit in your processing sketchbook directory as an extra library.

  5. Pingback: seucolega
  6. I had to write
    cam.start();
    in setup() after cam=new GSCapture(this,640,480);

    Now it works,
    You don’t did that?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.