augmented card trick --

I just finished up the software on this AR card trick performed by marco tempest:

it’s based on work a project that theo and I have been developing, and it uses ARtoolkitPlus, the new 3ds loader addon and some opencv stuff. it was pretty fun to develop.

I would love to hear feedback and am happy to explain any parts of it…

hope you enjoy !

  • zach

Yes! saw this one this morning, what a great idea to combine AR and real world toghter. I think magic is a great idea to show this.

got some questions btw.

  1. As I research artoolkitplus It has been succeeded by Studierstube Tracker. Which version do u use? ARTOOLKIT+ or Studierstube Tracker

  2. I use ARToolkit before, but by this I always attack those ‘urgly’ marks to the object. from studierstube Tracker example looks cooler, which able detect pic instead special makrs. I guess it’s the how you track the cards. or?

  3. Last question, by search the Studierstube Tracker website, I dont see any link to download library, maybe I’m stupid, do u have any link of that?

From my understanding Studierstube Tracker is not publicly available - I think you have to get a commercial license to use it.

For the AR card stuff we were using ARToolkit++.

BTW the new openCV has features similar to Bazaar ( ) that lets you use an image instead of an AR marker.

ITs one of the demo apps in the 1.1pre release of openCV (which comes with 006 … thanks Todd! ).


Yeah, I saw it on vimeo, really great work. I enjoyed it even though I am not into magic tricks at all :).

Are there any recources on how to track custom objects like cards with ARToolkit?

hey zach!

thanks for the excellent ofxALSoundPlayer class - it worked perfectly out the box!
( I hooked it up for this little dj app I made: )

One thing I couldn’t find in it though a setPosition function - as in set the playback position within the track - ie setPosition(0.5) ( jump to half way through ).

Is that something that is missing from the SoundEngine class hence ofxALSoundPlayer?


Hey sorry was meant to post this here -> moved to

zach - hey that came out awesome!! damn, its come quite a ways since i saw it at eyebeam so long ago. did you build train it for each individual card? It looks like it works amazingly well!

theo - wrong subforum? i think? confused hahaha, but no problem! the scratch app you made with it was sick. did you manage to hack in setting track position? or did you figure out some other crazy way to do make it work?
the reason setPosition and getPosition werent in there is because they werent functions initially set up in apple’s soundEngine class which handles all the threading and buffer stuff/ I do want to get them in there eventually. The soundEngine class is pretty dense but im making some headway (i added the function to load a sound from an array, etc), so hopefully soon ill get that stuff working

Hey zach

wow! this is so nice! great! sweet! i was always wondering who are these people who are programming for marco tempest. ‘OF’ on the card! I think most parts of the trick is marcos ability to shuffle cards. more of that!
greetings ascorbin

what is ARToolkit ?

Wow, this came out amazing! Great work!
As for the studierstube tracker, you can actually download it and it doesn’t mention anything about a custom or paid licence, it’s just a bit of a hidden download it seems (got the link through the FAQ page). It’s here:

I think the only thing that needs a paid licence is their mobile phone tracking thingy.

Keep it up!

oh nice - that wasn’t there last time I checked!

Cool - so the race is on!
First to get it hooked into OF wins :slight_smile:


great! thanks a lot fiezi.

looks like of website. no direct link to access. LOL

sorry for the delay and thanks for the nice feedback… :slight_smile:

I’m including some details about how the trick is done:

the way the tracking is done is pretty simple, but I’ll try to make an example to show when I get a moment:

a) find a objects of a certain size.
b) look for corners (ie, areas of high curvature)
c) if you have 4, look that the lines in the non curvature region, extend them out, and where they intersect are the corners. this makes corners stable.
d) if those lines are not parallel enough drop this blob
e) if the blob is not really in the right aspect ratio, drop the blob
f) then, fit a “square” in the rectangular 4 lines by orienting the corners of the square to the long side of the lines.
g) pass that square into arToolkit as the detected corners of a marker and, you get that tranform as if a marker is really there.

theo developed this sweet technique, which is a (smart) hack of ARTookltPlus, and I pushed steps (b c and d) to make the card detection and tracking stable.

With this card trick performance, identifying the type of card wasn’t so important to track (since I knew the order of the trick) but we’ve done some work on this. I do need to track age of cards, and to make graphics not disappear when cards are obscured, etc. There are also some opencv specific stuff to take snapshots of cards as they are detected, for the levitating cards, for example.

hope that’s a good explanation…

take care!

That video was inspiring. I’m finally committing to a transition to openframeworks form actionscript because of it.

Any chance you guys might post the barebones project of loading custom markers for xcode? It was way easier in both flash and the old artoolkit. I’ve been tinkering with the project files, associating 3ds files and making a simple animation engine, but the custom marker thing has me stumped.

thanks for the inspiration and any help,

Hey Zack,
i’m relatively new to Artoolkitplus and openGL

i’m having a tough time getting the image i capture through openCV to be set as the background image in OpenGL …

I also cannot convert the image i take through the camera using opencv to be scaled to 320x280 from 640x480 …
i also have to save my image and load if for things to work…

here’s my code


int findMarker()
IplImage* image = cvQueryFrame( capture );

if( !capture ) {
fprintf( stderr, “ERROR: capture is NULL \n” );
return -1;
if( !image ) {
fprintf( stderr, “ERROR: frame is null…\n” );

//cvShowImage( “Capture”, frame );
//image = cvCloneImage( frame );

if(!cvSaveImage(“immagineTmp.jpg”,image)) printf(“Could not save\n”);

image = cvLoadImage(“immagineTmp.jpg”, 1);

cvShowImage( “Image”, image );


glGenTextures(1, &bgid);
glBindTexture(GL_TEXTURE_2D, bgid);

// Create Linear Filtered Texture
glBindTexture(GL_TEXTURE_2D, bgid);
glTexImage2D(GL_TEXTURE_2D, 0, 3, image->width, image->height, 0, GL_RGB, GL_UNSIGNED_BYTE, image->imageData);

glBindTexture(GL_TEXTURE_2D, bgid);


glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.2f, -1.0f, -2.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.2f, -1.0f, -2.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.2f, 1.0f, -2.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.2f, 1.0f, -2.0f);



// do the OpenGL camera setup

int markerId = tracker->calc((unsigned char *)(image->imageData));
float conf = tracker->getConfidence();

// use the result of calc() to setup the OpenGL transformation

printf("\n\nFound marker %d (confidence %d%%)\n\nPose-Matrix:\n “, markerId, (int(conf*100.0f)));
for(int i=0; i<16; i++)
printf(”%.2f %s", tracker->getModelViewMatrix()[i], (i%4==3)?"\n " : “”);

return 0;

@ usamsam: please don’t double post. we use RSS around here, and will see what you ask when you ask it. also, you’re asking about general opencv/ opengl question - this is a forum about openframeworks.