Squirreltech

May 18, 2010

AR Finger Tracking

Filed under: Uncategorized — squirreltech @ 8:58 pm

Well, i’m back again. I am using the processing platform to play with this stuff, because it is so easy to make graphic applications and in very few lines, you can get something up and running.

So, I was very happy to find the SimpleARToolkit. This is a wrapper for the jARToolkit which it self it a wrapper for the ARToolkit. jARToolkit doesn’t seem to be in active development any more, which I think is a bummer because I really don’t want to go back to C/C++ to do coding. I like Java 😦 Sigh….

Anyway, I did have some good results with an AR marker. This is simply a black and white image that is not symmetrical left to right or top to bottom. The code knows the image as some kind of “patt” file, which is probably just short for pattern. This is really nice because the image can be generated and chances of it appearing in the background are very slim. Additionally, the application can assign “up”, which means I can turn my finger relative to the camera and the code recognizes this.

Check out the video below. Then the code afterward.

Code:

import JMyron.*;
import processing.opengl.*;
import pARToolKit.SimpleARToolKit.*;

JMyron m;
PImage img;
SimpleARToolKit hiro;
SimpleARToolKit ren;
int capWidth, capHeight;

void setup() {

  capWidth = 320;
  capHeight = 240;
  size(capWidth, capHeight, OPENGL);
  m = new JMyron();
  m.start(capWidth, capHeight);
  m.findGlobs(0);
  img = createImage(capWidth, capHeight, ARGB);
  hiro = new SimpleARToolKit(this, capWidth, capHeight);
  hiro.loadPattern("patt.kanji", 80, 0.0f, 0.0f);
  hiro.register("showBox");

  stroke( 0, 255, 0 );
}

void draw() {
  background(0);
  m.update();
  m.imageCopy(img.pixels);
  img.updatePixels();
  hint(DISABLE_DEPTH_TEST);
  image(img,0,0,width,height);
  hint(ENABLE_DEPTH_TEST);
  if (hiro.findMatch(img,100)) {
    hiro.showObject();
  }
}

void showBox(SimpleARToolKit _a) {
//  noFill();

  strokeWeight(4);
  line( 25, 0, 25, 50);
  line( 25, 50, 0, 25 );
  line( 25, 50, 50, 25 );
//  box(50);

}
Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: