Artoolkittracker mac

From Wiki for iCub and Friends
Jump to: navigation, search


ARToolKit adapts its global settings like the pixel format to the operating system where it is compiled on. That means it is per se not configured to work with the image format used by the frame grabbers provided by yarp. The module in the icub repository was originally written for Windows and Linux and supports their image formats. Unfortunately when the yarp independent source code is compiled under Mac OS X, the default pixel format is set to ARGB. This works fine when used independently from the repository module but it will make said module crash as the yarp frame grabbers deliver a RGB pixel format. For the default pixel format under Windows, which is set to BGRA (ARToolKit viewpoint) there is a opencv conversion from the the pixel format delivered by the grabber (RGB) to the pixel format that is assumed by the ARToolKit libraries when compiled under Windows (BGRA). In the case of Linux it is even easier as most image/frame grabber frameworks like Video for Linux (V4L) or GStreamer produce the RBG pixel format so that no conversion is necessary. When compiled under Mac Os X ARToolKit sets the default pixel format to ARGB. Unluckily the OpenCV conversion command (cvCvtColor(..)) doesn't seem to be able to perform this particular conversion (RGB2ARGB). Therefore the easiest way to get the ARToolKit module to work under Mac OS X is to re-compile ARToolKit itself before compiling the module in the repository (which uses the libraries from your custom ARToolKit installation) and to 'tell it' explicitely that we are expecting our images to be of the type RGB and not ARGB despite beeing on a Mac Os machine.


The easiest way to get the ARToolKit tracker module to run under Mac OS X is to recompile ARToolKit. Edit AFTER having called ./configure the header file that sets the global constants like the default pixel format. Note that this edit most probably will cause problems with the standalone ARToolKit programs but it will enable you to use the ARToolKit tracker module from the repository without any changes. In






and call make.

Potential future solution:

Add an additonal OS switch for Mac Os (#ifdef __APPLE__) and write an image conversion method that does the RGB2ARGB conversion. Call this method from ARToolKitTracker::detectMarkers( IplImage *iplimg) in $ICUB_ROOT/src/artoolkittracker/ARToolKitTracker.cpp.