Category Archives: nerd

Processing + NyARToolkit + multiple marker tracking

For various reasons, I need to do multiple marker tracking in processing with NyARToolkit.  However, with the default NyAR4psg layer between these two, multiple marker tracking is downright hard, and when you get it working, it’s not quite what you expect. After a few days of Java hacking, during which I was very pleasantly surprised with eclipse, I am now pleased to present to you my modifications to the NyAR4psg that makes multiple marker tracking easy! See here:

Standard hiro and kanji markers tracked simultaneously with augmented reality sphere and cube. In the background some artwork by my daughter!

I’ve called it NyARMultiBoard, and you can use it instead of the default NyARBoard if you want to track multiple markers.

Download a ZIP file containing everything (source code, jar files) from this directory.  If you unpack this into your processing sketchbook/libraries directory, it should work out of the box.  It’s a drop-in replacement for NyAR4psg, so you don’t need to have that installed as well. There is an example to get you started in NyAR2/example/NyARMultiTest.  Note: This uses the GSVideo capturing stack as I explain here, you should easily be able to change it back to processing defaults (just change GSCapture to Capture).

Please let me know in the comments if this works (or doesn’t) for you!

I made this screencast to demonstrate the multiple marker tracking, assisted by TNR:

YouTube Preview Image

I also made this really bad screencast (old webcam + night time lighting + transcoding):

YouTube Preview Image

If you’re really into the details

I’ve just added two new classes NyARMultiBoard and NyARMultiBoardMarker to the default NyAR4psg distribution. Very importantly, NyARToolkit itself needs to be patched with one extra method in NyARDetectMarker, see the NyARMultiBoard comments.

Update on 20110304

I’ve fixed the problematic frame bug in gsvideo that many of you have been running into. See this post.

Update on 20110305

I’ve updated NyAR2 so it works with the P3D renderer as well, which is often faster for blitting the webcam image onto the display. The updated zip file is named NyAR2-20110305.zip, and it can be downloaded from the usual directory. My changes are based on NyAR4psg 0.3.0 and NyARToolkit 2.5.2.

An Even More Ultimate Boot Disk!

In this short howto, I show you how to combine the Ultimate Boot CD (UBCD) with both Knoppix 6.2.1 and Ubuntu 10.04 onto a single USB stick to create An Even More Ultimate Boot Disk (EMUBD)!

UBCD is a bootable CD image that’s fantastic if you’re trying to save grandma’s PC from a certain death, as it contains a number of different bootable utilities for testing memory, testing and low-level repair of hard drives, partition repair, antivirus and so forth. It even contains Parted Magic, a compact linux distribution for fixing partitions, amongst others.

Knoppix is the swiss knife of live linux distributions, and Ubuntu 10.04 is probably the slickest distribution out there at the moment. Both of these can be ran live from your USB disc, so they don’t have to touch your hard drive.  However, both of them are also able to install to your hard disc if you so choose.

To me it seemed logical to combine all three of these elements onto the single USB flash drive that I carry on my keychain, as I know of many grandmas with broken PCs…

Let’s go!

  1. make sure the single FAT32 partition on your USB stick is bootable (use command ‘a’ in linux fdisk) and large enough (you’ll need just a bit less than 2G).
  2. mount your flash drive on a directory, henceforth referred to as FLASH_MNT.
  3. copy all files from the ubcd5 iso into a directory, henceforth referred to as CUSTOM_UBCD5.
  4. mount the ubuntu 10.04 i386 iso on a directory, henceforth referred to as LUCID_MNT
  5. mount the knoppix iso on a directory, henceforth referred to as KNOPPIX_MNT.
  6. copy necessary boot files from the ubuntu ISO to UBCD:
    mkdir CUSTOM_UBCD5/ubcd/custom/lucid
    cp LUCID_MNT/casper/vmlinuz LUCID_MNT/casper/initrd.lz CUSTOM_UBCD5/ubcd/custom/lucid
    
  7. copy ubuntu-10.04-desktop-i386.iso to your flash disk:
    mkdir /FLASH_MNT/isos
    cp ubuntu-10.04-desktop-386.iso /FLASH_MNT/isos/
    
  8. Knoppix can’t be booted directly from its iso like Ubuntu, so we have to copy the actual contents of the ISO to your flash:
    cp -r KNOPPIX_MNT/KNOPPIX to FLASH_MNT/
    cp -r KNOPPIX_MNT/boot/isolinux to FLASH_MNT/KNOPPIX/isolinux
    
  9. replace FLASH_MNT/KNOPPIX/isolinux/isolinux.cfg with the isolinux.cfg at the bottom of this post. (It’s the same file, except that “KERNEL linux” is replaced with “KERNEL /KNOPPIX/isolinux/linux”, “initrd=minirt.gz” with “initrd=/KNOPPIX/isolinux/minirt.gz”, F1, F2, F3 and DISPLAY paths all fixed, e.g. “F2 f2″ becomes “F2 /KNOPPIX/f2″ and finally all instances of “quiet” removed)
  10. Now replace CUSTOM_UBCD5/ubcd/custom/custom.cfg with the custom.cfg at the bottom of this post.
  11. copy all files from CUSTOM_UBCD5 to your usb flash disk:
    cp -r CUSTOM_UBCD5/* FLASH_MNT/
    
  12. Finally, make the whole thing bootable with the following invocation. It’s really important that you replace /dev/sdX1 with the correct device for your flash disk. To see what this is, type “mount” and see the device associated with your FLASH_MNT.
    cd FLASH_MNT
    sudo ./ubcd/tools/linux/ubcd2usb/syslinux -s -d /boot/syslinux /dev/sdX1
    

You’re done. You should now be able to boot with your EMUBD! Knoppix and Ubuntu can be found under “User defined”.

Here are those files that you’ll need. First FLASH_MNT/KNOPPIX/isolinux/isolinux.cfg:

DEFAULT knoppix
APPEND ramdisk_size=100000 lang=en vt.default_utf8=0 apm=power-off vga=0x311 initrd=/KNOPPIX/isolinux/minirt.gz nomce loglevel=0 tz=localtime
TIMEOUT 50
# TOTALTIMEOUT 20
# KBDMAP german.kbd
PROMPT 1
F1 /KNOPPIX/isolinux/boot.msg
F2 /KNOPPIX/isolinux/f2
F3 /KNOPPIX/isolinux/f3
DISPLAY /KNOPPIX/isolinux/boot.msg
LABEL adriane
KERNEL /KNOPPIX/isolinux/linux
APPEND ramdisk_size=100000 lang=en vt.default_utf8=0 apm=power-off vga=0x311 initrd=/KNOPPIX/isolinux/minirt.gz nomce loglevel=0 tz=localtime adriane
LABEL knoppix
KERNEL /KNOPPIX/isolinux/linux
APPEND ramdisk_size=100000 lang=en vt.default_utf8=0 apm=power-off vga=791 initrd=/KNOPPIX/isolinux/minirt.gz nomce loglevel=0 tz=localtime
LABEL fb1024x768
KERNEL /KNOPPIX/isolinux/linux
APPEND ramdisk_size=100000 lang=en vt.default_utf8=0 apm=power-off vga=791 xmodule=fbdev initrd=/KNOPPIX/isolinux/minirt.gz nomce loglevel=0 tz=localtime
LABEL fb1280x1024
KERNEL /KNOPPIX/isolinux/linux
APPEND ramdisk_size=100000 lang=en vt.default_utf8=0 apm=power-off vga=794 xmodule=fbdev initrd=/KNOPPIX/isolinux/minirt.gz nomce loglevel=0 tz=localtime
LABEL fb800x600
KERNEL /KNOPPIX/isolinux/linux
APPEND ramdisk_size=100000 lang=en vt.default_utf8=0 apm=power-off vga=788 xmodule=fbdev initrd=/KNOPPIX/isolinux/minirt.gz nomce loglevel=0 tz=localtime
LABEL memtest
KERNEL memtest
APPEND foo
LABEL dos
KERNEL memdisk
APPEND initrd=balder.img
LABEL failsafe
KERNEL /KNOPPIX/isolinux/linux
APPEND ramdisk_size=100000 lang=en vt.default_utf8=0 vga=normal atapicd nosound noapic nolapic noacpi pnpbios=off acpi=off nofstab noscsi nodma noapm nousb nopcmcia nofirewire noagp nomce nonetwork nodhcp xmodule=vesa initrd=/KNOPPIX/isolinux/minirt.gz

… and then CUSTOM_UBCD5/ubcd/custom/custom.cfg:

MENU INCLUDE /ubcd/menus/syslinux/defaults.cfg
UI /boot/syslinux/menu.c32

# option to be able to go back to the main menu
LABEL -
MENU LABEL ..
COM32 /boot/syslinux/menu.c32
APPEND /ubcd/menus/syslinux/main.cfg

# this clause will boot directly from the ubuntu iso
LABEL ubuntulive
MENU LABEL Ubuntu 10.04 i386 Desktop LIVE
LINUX /ubcd/custom/lucid/vmlinuz
INITRD /ubcd/custom/lucid/initrd.lz
APPEND boot=casper iso-scan/filename=/isos/ubuntu-10.04-desktop-i386.iso --

# and this one will chain into the knoppix boot setup
LABEL knoppix
MENU LABEL Knoppix 6.2.1 LIVE
CONFIG /KNOPPIX/isolinux/isolinux.cfg

Post scriptum

  • The instructions in this post are derived from the UBCD linux documentation and various forum posts.  Credits to their authors!
  • If you don’t want Knoppix on your bootable USB and you have a Windows computer, you could also use MultiBootISOS to add multiple ISOs to a USB boot disk.

Weekly Head Voices #18: Refactor my dogfood.

Welcome all, to this, the 18th edition of the Weekly Head Voices, in which I discuss a number of issues that mostly have nothing specific to do with the 11th week of 2010, but which might or might not have crossed my mind during that time! Issues include good news on the EuroVis 2010 front, a new edition of the Head Voices Review featuring my completely unexpected stay in a 7 Tesla MRI scanner (as a test subject, of course)  and finally some nerdy backyard philosophy dealing with the well-known itch to Rewrite Everything From Scratch, Because What’s There Now Sucks.

First, because I have no other visual element for this week’s post, and  because I am, as you might have noticed, a method blogger, I present you with probably the best chatroulette.com improv I’ve ever seen so far. For those of you who have been completely asleep the past few weeks, chatroulette is a new site that’s been taking the interwebs by storm. The site pairs up random strangers for webcam chats. One is allowed to move to the next random stranger with the click of a buttom (resulting in the new English verb “to next” someone..). Random hilarity (and often perversity) ensues! Here’s that mostly SFW and brilliant piano improv:

YouTube Preview Image
(The original video had to be pulled, after 4 million views, due to some YouTube issues. Merton, pianist, has posted this new version. Thanks to Francois for the heads-up!)

Back to business, we have just heard the great news that our two EuroVis 2010 submissions have been finally accepted for publication.  The articles are:

  1. S. Busking, C.P. Botha, and F.H. Post, “Dynamic Multi-View Exploration of Shape Spaces,” Computer Graphics Forum, 2010.
  2. P.R. Krekel, E.R. Valstar, J. de Groot, F.H. Post, R.G. Nelissen, and C.P. Botha, “Visual Analysis of Multi-Joint Kinematic Data,” Computer Graphics Forum, 2010.

Fantastic work you first authors you! Remember people: YOU HAVE TO CITE THESE SOON, AND YOU HAVE TO CITE THEM OFTEN! This also means that a number of us will be going to Bordeaux in June (I can imagine worse places to go to in June) to mingle with other scientists and to drink really good red wine.

That good news brings us to the influential WHV feature, the Head Voices Review! (My TPN is still working on the new jingle.  Hopefully it’ll be on time for our joint Vodka review feature.) In this edition, I’ll be reviewing the Philips 7 Tesla MRI scanner and the JBL Duet-200 computer speakers.

On Friday, I unexpectedly had the pleasure of trying out a state-of-the-art 7 Tesla Philips MRI scanner, as a test subject. I can report that the bore, although small, is quite comfortable. However, test subjects with claustrophobic tendencies should probably look elsewhere.  Scanning can be quite noisy, especially when a diffusion weighted imaging protocol is applied that involves scanning in 162 different gradient directions (to study the structural connectivity in my brain). However, the music that gets piped in between scanning sessions more than makes up. After scanning, it was scientifically confirmed that there is indeed a brain housed in my skull, an observation that pleasantly surprised me. Soon I hope to be able to post visualisations, made by one of our MedVis ninjas, of the structural connections in my brain.

All in all, if you have a few million euros lying around, this piece of kit is highly recommended.  To summarise:

  • Philips 7T MRI: AWESOME.

In a previous review, I was quite negative about the Logitech S3-30 speakers, for a large part due to the absolute mess of cables that it comes with. This past week I took delivery of the new JBL Duet-200 speakers I ordered, for the grand amount of 30 eurobucks, to replace it. The JBL is a single unit containing two speakers, something which might be seen as a drawback, but which I consider an advantage. In spite of its compact appearance, it packs quite a base and more than sufficient volume.  In addition, there are exactly two (2) cables: One for the power supply, and one for the audio. I can only hope that Logitech contracts JBL on their next PC speaker product design. My only (minor) gripe is that the JBL-supplied audio cable is only about 40cm long. All in all:

  • JBL Duet-200 at € 30 price-point: AWESOME.

MRI scanners and PC speakers: No product too big, no product too small for the Head Voices Review!

Finally, it’s time for some backyard philosophy.  This week, it’s a brief point of really nerdy philosophy, although I think the principles apply to some non-nerdy activities as well. Software developers, as well as many other engineering types, often reach a point during working on a project, when they have a hard-to-control urge to trash the whole thing and start from scratch.  There is usually a very strong belief that the project / software / product can be designed much better by starting from scratch.

It turns out that this is an insidious and mostly incorrect belief, for a large part due to all the knowledge present in the existing “ugly” product that will get thrown out. Engineers easily underestimate the importance of this knowledge. It turns out, much as we don’t like to hear this, that refactoring is, nine times out of ten, a far better answer than rewriting from scratch. Experienced developers know this, and are mostly able to suppress the rewrite from scratch itch.

Joel Spolsky wrote a really good essay on this phenomenon. Go read it!

Weekly Head Voices #16: Go Go Gadget!

This post is dedicated to my man Helmut in Vienna.  Your appreciation is much appreciated!

In this edition, I report on my productivity and activities of the past week,  extol the time-saving virtues of iGoogle and conclude with a new WHV feature: The Head Voices Review!  Unfortunately, due to a chronic lack of sleep, there will be no backyard philosophical contribution.  We hope to be back on track for the next edition.

During week 9 of 2010, the temporal context of the sixteenth edition of the Weekly Head Voices, I spent 2 hours preparing for lectures, 3 hours lecturing and 12 hours in scheduled meetings.  I spent a significant amount of time assisting five of our MedVis Ninjas shepherding papers out the door, so now you have to cross your fingers that we get 100% accept rate, else the Ninjas get really angry.  Counting up to the weekend, and without any cheating, I completed 22 GTD tasks, again one task more than last week.  If this continues, I will eventually attain infinite productivity, so you better watch out, ok?

Noteworthy happenings include two Skype Video meetings, which worked really well and saved me a significant amout of travel time. These meetings would be even better if my correspondents would invest in webcams, allowing me to look at more than just my own face during the discussion. In other news, I’ve been spending even more time futzing around with processing, resulting in a first blog post detailing the installation of said library with video capture and augmented reality support on 64 bit Linux machines.

The main topic of this post is gadgets. I’ll be talking about two kinds of gadgets, so first I’d like to start with a screenshot of my iGoogle:

iGoogle your twitter.

I’ve been aware of iGoogle, and used it as a poor man’s aggregator before getting addicted to Google Reader, but never really appreciated the possibilities.  In short, you can add all kinds of web applications, called gadgets, to any number of tabs (each tab is a page), thus mixing and matching for example the social networking websites you use on one single web page.  Because I’d recently been wasting far too much time switching between twitter, facebook (everytime someone mentions facebook, I somehow reflexively and compulsively open the site, hence wasting more precious minutes of my life, which at my advanced age is no small matter), gmail and compulsive news checking, I decided to compress my time wasting into a single page visit. So far, it seems to be saving me a number of minutes every day, minutes that I’m saving for later…

Finally, it pleases me greatly to be able to introduce a new feature on the WHV: The Head Voices Review! [As soon as my TPN completely masters Ableton, I'm hoping he'll make me a nice theme song that I can insert here.] Some of you might know that this blog has a rich history in reviewing gadgets. See for example this post where, after weeks of investigation, I posted an in-depth review of not one, but TWO cheap-skate headphones.  To summarise:

  • Sennheiser PX20: SUCKS.
  • Philips HP-200: AWESOME.

To kick off this first edition, I’m going to discuss three more computer audio gadgets.  First off, the Logitech S3-30 2.1 (that means stereo speakers with sub-woofer to my non-audiophile readers) computer speaker set with built-in amplifier.  I’ve used these extensively for five years now (purely for the purposes of reviewing them of course) and have set out my conclusions in the table below:

  • Logitech S3-30: SUCKS BADLY.

I base my conclusion on the sub-par design of these speakers, especially in terms of the cabling.  Below is an artist’s rendition of the cable design for these speakers:

Artist's rendition of Logitech S3-30 speaker set cable design. Note the bird's nests.

As you can see, it’s as if the engineers had been challenged to see how much cable they could waste in producing these speakers, and as a side-challenge, how they could ensure that any desk carrying these speakers would instantly turn into an unmanageable mess of cables in various states of entanglement.  Why why why didn’t they read this really important paper?

I have recently ordered the JBL Duet 200 to replace the S3-30.  After at least five more years of extensive testing, I will document its performance in a future Head Voices Review.

On the topic of Logitech, a number of my screencasts up to now have been performed using a Logitech Analog Desktop Microphone with 3.5mm jack plug, purchased especially for that purpose.  Now that I’ve also purchased the quite affordable (6 bucks for the whole headset, that means headphone AND microphone!) yet very stylish Sweex HM400 headset, also for recording screencasts, I can present the following comparative review:

  • Logitech Analog Desktop Microphone with 3.mm jack plug: SUCKS.
  • Sweex HM400 headset: AWESOME.  Wait till you hear my deep baritone narrating the next screencast.  I expect that it should sound almost exactly like this:
YouTube Preview Image

Err, that’s it for the first edition of the Head Voices Review! I don’t think that you have to worry too much about the next edition arriving anytime soon.  Here at HVR headquarters we take our sweet time, as we pride ourselves in jumping to all of the wrong conclusions, all of the time.

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:

YouTube Preview Image

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!