This project was intended to provide a simple wrapper for the ARToolKit. To use its functionalities also in other programming languages (like in our case Python), than only C. I get the video-frames from wherever I want and overlay the video-frame with whatever I want (mainly VTK). So you are no more bound to capture your video-frames with ARToolkit, and use C and OpenGL for the visualization.




Download the ARToolkit from and compile it, I would recommend the latest version 2.72.1 and a compilation with GStreamer (possibly the easiest way).


I recommend the usage of GStreamer, I use it in all examples to grab frames from the webcam, and it is easy to configure. Have a look at the Python-GSreamer Tutorial by Jens Persson for further information:


To be able to compile ARToolkit-ICE you will need to generate the interface for the target-language with SWIG.


And of course, you need AR-ICE (the ARToolKit-InterfaCE or ARToolKit is Complicated Enough), which can be downloaded under:


Compilation: Default target language is Python

There are only two things you have to take into account if you want to compile the ARToolkit-Interface:

  1. Open the Makefile and change the path to the ARToolkit installation, that means change variable ARTOOLKIT.
  2. Check the other include directories under INC_DIR and of course you need the Python header files, so check INC_PYTHON, maybe you have Python2.7. I also checked the compilation with Python3.0, but if you are using pyVTK you will get in trouble, currently there is no pyVTK support for Python3.0.

That was all, just type in make an run the compilation.


Running the examples (Python)

First of all, go to examples/Data and print out the marker “pattSample1.pdf”. And afterwards try the examples under examples/Python.

The Basics

Now, there are only a few lines of code you require to have the ARToolkit-functionality in you Python-script:

# Of course, import the module
import artoolkit as ar

# Set the camera-parameter and image-size
ar.VideoParameter("camera_para.dat", 640, 480)

# generate a new marker, or simply if you just use standard-markers
# pattern = ar.MakePattern(".patt.sample1")
pattern = ar.MakePattern("patt.sample1",80,0,0)

# load the pattern to artoolkit with

# thats all, we can now search for markers in the video-frames (100
# is the black-white threshold in artoolkit) ...
# all detected markers are stored in arMarkerInfo
arMarkerInfo = ar.DetectMarker(videobuffer, 100)

# to check if your registered marker was found, use:
if ar.FindPattern(arMarkerInfo, pattern):
    # If the marker was detected, all necessary information is stored in
    # the variable pattern
    # get the ARToolkit-transformation-matrix
    print pattern.dTransformationMatrix

    # get the confidence
    # (-1, if the marker was not found, otherwise a value dCF 0<= dCF <=1)
    print pattern.dCF


Have a look at the examples in examples/Python, were the camera parameters were transformed, (a bit tricky) but I hope self-explanatory…

Additional functionality that is currently available is:

ar.glCameraView  (double para[3][4], double scale = 0)
ar.glCameraViewRH(double para[3][4], double scale = 0)
ar.glCameraFrustum  (ARParam *cparam, double focalmin, double focalmax)
ar.glCameraFrustumRH(ARParam *cparam, double focalmin, double focalmax)

this functions were taken from gsub_lite, if you require additional functionality, add it to artoolkit.cpp\h and extend the definitions in artoolkit.i (swig-file).


Usage with other languages

Unfortunately there is currently only Python-Support, but if you need require an interface for another language you will have to add a new typemap (see typemaps/python.i, as an example). And include the new typemap into artoolkit.i using SWIG-defines:

    %include typemaps/(target).i

Changing the Makefile:

  1. Change TARGET
  2. Include the addional headers (see INC_PYTHON)
  3. Add additional information for SWIG_FLAG and REMOVE

Thats all folks …


Known Limitations

There are currently some minor projection problems with other camera resolutions than 640×480. Thanks for any suggestions đŸ˜‰


Readers Comments (2)

  1. Great blog post thanks for posting

  2. I really like what you guys are usually up too.

    This kind of clever work and coverage! Keep up the amazing works guys I’ve
    you guys to my personal blogroll.


Leave a comment

Your email address will not be published.