ARToolKit support.


I just added the necessary glue code to connect Panda3D to the ARToolKit, which is a library for augmented reality applications.


What’s augmented reality?

Assertion Error on OpenCVTexture()

Well, let me tell you what ARToolKit does. With the help of a webcam, it can do limited computer vision. The only thing it can see are these special glyphs that are specifically designed to be easy for it to pick out of a scene. However, it can see them fairly reliably, and it can also tell where they are in space and how they’re oriented. You can use this to infer the position of larger objects: let’s say you glue a glyph to, oh, a remote control car. The system can see the glyph, and from that, it can figure out where the car is. Then, you can put the webcam output on the screen, and superimpose 3D graphics. You can even make it look like the 3D objects are riding in the real physical RC car.

If you’ve seen the TV ads for the game “Eye of Judgement,” that’s using augmented reality - it can see the glyphs on the cards, and it can superimpose dragons and things.



I may just try to compile Panda for the first time then !!!


thats indeed a really sweet toy . like to try it out myself thought i cant at the moment. it sorta allows quite cheap and still fancy interfaces.
i wonder if it could be used for motion-tracking if you stick small cardboards all over yourself…
anyway. very nice toy you gave us :slight_smile: THX a lot!


I gotta warn you, though: it’s finicky.


Finicky and enough documented means less garbage in :slight_smile:


Hmmm… sounds quite interesting :smiley:
I wonder what sorts of things from “real life” it can “read”…
Could be something like EyeToy (Playstation).

Regards, Bigfoot29


So by using the ARToolKit does that mean Panda3D could do something like this:

If so…man! Thats what I was waiting for!..
I am sorry I misunderstood, did you say it is ready to implement/download or in development?

Anyway awesome contribution.


It’s fully operational. Very little python code needed to get it working. However, to use it, you have to fetch the latest version from CVS. Then, you have to get the thirdparty libraries from the website. Finally, you have to add the ARToolKit to the thirdparty libraries, because I haven’t published a version of the thirdparty libraries that include ARToolKit yet. Then you compile.

It’s all a bit of a pain.


is there an example somewhere on how to use artoolkit and panda3d?


Afraid not. I slapped it in there last semester for a team here at CMU that was using it, so I never got around to creating a sample. I really need to do this. How urgent is it?


it’s not urgent, no rush on this. taking the time to answer is really nice of you, of course, if you can find the time this summer to make a working example that would be very neat.



a working sample would be awsome!!!
Did somone got the toolkit to work with panda?
What are the steps to do it?


install panda3d

from pandac.PandaModules import *

tex = OpenCVTexture()

b = loader.loadModel("panda")
ar = ARToolKit.make(, "./camera_para.dat", 1)

ar.attachPattern("./patterns/4x4_6.patt", b)

def setupAR(task):

  ar.analyze(tex, False)
  return Task.cont

note thats not a compelte sample. but it should be the most essential part to get it working (under linux, for windows you need to use webcam input instead of openCV texture). i can try to upload a working sample in the evening.


Thank you very much for taking your time and helping a poor noob out ^^

I’m a 3D-Artist, so the whole coding-stuff is a mindtwisting nightmare for me…but i wanna get it work ^^

A working sample would be realy realy nice, i’m using panda on Windows.



I’m sorry i dont have windows, nor do i have access to any windows machine right now so i cant provide you with a working example for it.
But you can get a simple, somewhat over-commented sample running fine on linux here:

to make it work under windows see the code-comments. it should not be that hard. just a matter of changing the webcam input to WebcamVideo.
everything you need should be included. the patterns and camera-calibration files are taken from the original artoolkit-sources.


Again, Thank you verry verry much, it helps allot! Very nice of you, taking your time and helping me out! I switched from Panda 1.6 to 1.5.4 today to get shadows + normalmaps working, but i read that there seems to be a problem with webcamvideo in v1.5.4 (and i have atm no webcam avvailible for testing, but i will tomorrow…)

many greeetingz


hi thomas

do you have your example in c++

or know who to use the openCVtexture in c++

i am trying to convert your sample

my efforts are here


Anyone know how to correct this following error: I’m just trying the sample provided above in this thread. I didn’t modify anything. I don’t think there’s a problem with my webcam- I’ve gotten it to do some basic stuff with OpenCV.

DirectStart: Starting the game. PANDA3D ver. 1.7.0
Known pipe types:
(all display modules loaded.)
SIZE = 640, 480
Distortion factor = 318.500000 263.500000 26.200000 1.012757
700.95147 0.00000 316.50000 0.00000
0.00000 726.09418 241.50000 0.00000
0.00000 0.00000 1.00000 0.00000
Assertion failed: (xsize > 0) && (ysize > 0) at line 287 of c:\buildslave\dev_win32\build\panda3d\panda\src\vision\arToolKit.cxx
Traceback (most recent call last):
  File "", line 43, in updatePatterns
    ar.analyze(tex, False)
AssertionError: (xsize > 0) && (ysize > 0) at line 287 of c:\buildslave\dev_win32\build\panda3d\panda\src\vision\arToolKit.cxx
:task(error): Exception occurred in PythonTask update-patterns
Traceback (most recent call last):
  File "", line 50, in <module>
  File "C:\Panda3D-1.7.0\direct\showbase\", line 2531, in run
  File "C:\Panda3D-1.7.0\direct\task\", line 496, in run
  File "C:\Panda3D-1.7.0\direct\task\", line 454, in step
  File "", line 43, in updatePatterns
    ar.analyze(tex, False)
AssertionError: (xsize > 0) && (ysize > 0) at line 287 of c:\buildslave\dev_win32\build\panda3d\panda\src\vision\arToolKit.cxx