Tag Archives: ARToolKit

Installation scripts for ARToolKit, Collada DOM, OpenSceneGraph and osgART

I’ve created some scripts and patches so installation of all this libraries will be much less painful. The patches fix the compatibility issues with Ubuntu 11.10 and 12.04 I explained in other post and some small bugs in osgART and ARToolKit (you can also add support of V4L2 to it, credits to Kameda Yoshinari for this). I still have to test those on some versions of Ubuntu but I think they work quite well and if something goes wrong they are quite self explanatory and you’ll be able to fix them (would be nice if you tell me what you changed so I can improve them for us all ;) ). If you find any errors or a way to improve them don’t hesitate to comment here or in my Github repository. You can download all the files from here:

https://github.com/enekochan/installation-scripts

You should download all the files and place them in the same folder to proceed with the installation. The correct order to execute those scripts is:

  1. installARToolKit.sh
  2. installCollada.sh
  3. installOpenSceneGraph.sh
  4. installosgART.sh

Once you install all the libraries you will be able to use osgART with Collada (.dae) files as I do in this picture:

Don’t worry I’ll explain very soon (and with source code of course) how this is done.

UPDATE: You can find here the source code for this augmented reality application!

ARToolKit with OpenKinect using the IR camera

More than one year ago I started adding Kinect support to ARToolKit using libfreenect. I had some results but didn’t have enough time to publish a fully tested version of it. Now I know it ins’t very useful because Ubuntu already detects Kinect as a webcam (creating a /dev/videoX device for it, or at least that happend to me with Ubuntu 12.04 UPDATE: I figured out that this happens because of the gspca_kinect module introduced in Linux 3.0 kernel), so you can use it with ARToolKit via the GStreamer video input. Still I wanted to learn more on how ARToolKit works on its inside. Now I’ve added some more features and support not only for the RGB camera but also for the IR camera, tilt and LED.

The nature of the IR camera makes detecting markers very difficult as they are very blurry when not very close to the Kinect, but hey it’s been fun hacking with libfreenect. I’ll try to publish the code ASAP. I still want to test it more.

Install osgART 2.0 RC3 with OpenSceneGraph 2.8.3 or 2.9.6 with Collada support in Ubuntu 12.04

Before installing osgART we need to install ARToolKit, collada-dom and OpenSceneGraph so look at those post before continuing with this:

Once you have installed the dependencies for osgART download osgART 2.0 RC3 code from here and uncompress it. Run the following commands:

mkdir build
cd build
cmake .. -DCMAKE_CXX_FLAGS=-fpermissive -DCMAKE_MODULE_LINKER_FLAGS=-lgstreamer-0.10 -DCMAKE_SHARED_LINKER_FLAGS=-lgstreamer-0.10
make
sudo make install

You can remove the “-DCMAKE_CXX_FLAGS=-fpermissive” option if you add the following includes in the “include/osgART/Utils” file after “#include “:

#include 
#include 

Configure the ARTOOLKIT_CONFIG variable (you should have this already configured when installing ARToolKit):

export ARTOOLKIT_CONFIG="v4l2src device=/dev/video0 use-fixed-fps=false ! ffmpegcolorspace ! capsfilter caps=video/x-raw-rgb,bpp=24 ! identity name=artoolkit ! fakesink"

And run the example program while showing the “Hiro” pattern to the camera:

cd /usr/local/bin/
./osgartsimple

If you get this error:

Plugin '-1' unknown!
Could not initialize video plugin!

It is caused because the osgART libraries weren’t correctly copied to the library folder (“/usr/local/lib“) and/or the OSG plugins folder (“/usr/local/lib/osgPlugins-X.X.X“). Verify that a file called “libosgART.so” is in “/usr/local/lib” and that the files “osgdb_osgart.so“, “osgart_tracker_artoolkit2.so” and “osgart_video_artoolkit2.so” are in the OSG plugins folder (that should be “/usr/local/lib/osgPlugins-2.8.3” or “/usr/local/lib/osgPlugins-2.9.6” depending on the version of OSG you installed). Be aware that if you install different versions of OSG at the same time the osgART plugin may no be copied to the plugin folder of the OSG version you want. Also you may run this just in case:

sudo ldconfig /etc/ld.so.conf

If you see a black background it is caused because of a small bug in ARToolKit. It can be fixed in ARToolKit changing “ar2VideoCapNext” function on “lib/SRC/VideoGStreamer/video.c line 378 to return 0 instead of TRUE OR by changing osgART file “src/osgART/Video/ARToolKit/ARToolKitVideo.cpp” on line 310 from this:

if (0 == ar2VideoCapNext(video))

To this:

if (ar2VideoCapNext(video))

If you want to have a smoother marker detection on osgART you can change the source code on file “src/osgART/Traker/ARToolKit/SingleMarker.cpp” and uncomment the line 76 and comment the line 77. I mean changing this:

//arGetTransMatCont(markerInfo, patt_trans, patt_center, patt_width, patt_trans);
arGetTransMat(markerInfo, patt_center, patt_width, patt_trans);

To this:

arGetTransMatCont(markerInfo, patt_trans, patt_center, patt_width, patt_trans);
//arGetTransMat(markerInfo, patt_center, patt_width, patt_trans);

Sources: http://projects.springlobby.info/issues/1575
https://github.com/bitcoin/bitcoin/pull/456
https://code.ros.org/trac/opencv/ticket/1020
http://forum.openscenegraph.org/viewtopic.php?t=7755

Install ARToolKit 2.72.1 in Ubuntu 11.10 and 12.04

The installation process is the same as in Ubuntu 10.10 but it looks like there is a problem when executing the configure script. When running “./Configure” the gstreamer libraries are not correctly configured in the GST_LIBS variable. Here is how it is defined in the script:

GST_LIBS=`pkg-config --libs gstreamer-0.10`

You can fix this problem by manually adding the GST_LIBS variable to the definition of the LIBS variable:

LIBS="-lpthread -lglut -lGLU -lGL -lXi -lX11 -lm $GST_LIBS"

You can also add the result of executing the “pkg-config --libs gstreamer-0.10” command to that variable, both will make LIBS have this value:

LIBS="-lpthread -lglut -lGLU -lGL -lXi -lX11 -lm -pthread -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lxml2 -lgthread-2.0 -lrt -lglib-2.0"

You may also have some problems with V4L when executing make, this is caused because they changed the “linux/videodev.h” header file name to “libv4l1-videodev.h”. If you have that problem change the header file name in those files of ARToolKit:

include/AR/sys/videoLinuxV4L.h
lib/SRC/VideoLinuxV4L/video.c

Install ARToolKit 2.72.1 in Ubuntu 10.10

Firsts you have to install some dependencies:

sudo apt-get install freeglut3-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libxi-dev libxmu-headers libxmu-dev libjpeg62-dev libglib2.0-dev libgtk2.0-dev

Then download, extract, configure and compile the ARToolKit source code:

wget "http://sourceforge.net/projects/artoolkit/files/artoolkit/2.72.1/ARToolKit-2.72.1.tgz/download" -O ARToolKit-2.72.1.tgz
tar xzvpf ARToolKit-2.72.1.tgz
cd ARToolKit
./Configure
make

When configuring with ./Configure you can choose different video inputs. You should choose GStreamer (option 5):

"1: Video4Linux" for video capturers (with V4L version 1).
"2: Video4Linux+JPEG Decompression (EyeToy)" for Play Station EyeToy camera (with V4L version 1).
"3: Digital Video Camcoder throught IEEE 1394 (DV Format)" for firewire cameras.
"4: Digital Video Camera throught IEEE 1394 (VGA NONCOMPRESSED Image Format)" for firewire cameras.
"5: GStreamer Media Framework" for USB webcams.

Once all is compiled you have to copy the include files to /usr/local/include:

sudo cp -R ./include/AR /usr/local/include/

And the libraries to /usr/local/lib:

sudo cp ./lib/*.a /usr/local/lib/

In order to use pkg-config with ARToolKit we have to create a file in /usr/lib/pkg-config or /usr/lib/pkgconfig (it depends on the Ubuntu version). We have to create a file, while being super user, called AR.pc and fill with this:

prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include

Name: AR
Description: ARToolKit libs and includes
Version: 2.72.1
Libs: -L${libdir} -lARgsub -lARgsub_lite -lARgsubUtil -lARMulti -lARvideo -lAR
Cflags: -I${includedir}/AR

This way we can use pkg-config to create much more easy to use and read Makefile files:

$ pkg-config --cflags AR
-I/usr/local/include/AR
$ pkg-config --libs AR
-L/usr/local/lib -lARgsub -lARgsub_lite -lARgsubUtil -lARMulti -lARvideo -lAR

It is also recommended to add the library location path to the LD_LIBRARY_PATH environment variable. It can be done in “~/.bashrc” file in our home folder:

export LD_LIBRARY_PATH=/usr/local/lib

Before we run any of the example programs in “bin” folder of ARToolKit we MUST export a environment variable with the configuration of our capturing device. For example I use this one:

export ARTOOLKIT_CONFIG="v4l2src device=/dev/video0 use-fixed-fps=false ! ffmpegcolorspace ! capsfilter caps=video/x-raw-rgb,bpp=24 ! identity name=artoolkit ! fakesink"

Look carefully to the device I configured because it may not be yours (devide=/dev/video0). You can also configure the pictures  height and width, although your camera has to support those configurations to work properly.

export ARTOOLKIT_CONFIG="v4l2src device=/dev/video0 use-fixed-fps=false ! ffmpegcolorspace ! capsfilter caps=video/x-raw-rgb,bpp=24,width=640,height=480 ! identity name=artoolkit ! fakesink"

You can also use a input video file for testing purposes or to develops in a computer that doesn’t have a real video device:

export ARTOOLKIT_CONFIG="filesrc location=gstreamer_test_xvid.avi ! decodebin ! ffmpegcolorspace ! capsfilter caps=video/x-raw-rgb,bpp=24 ! identity name=artoolkit ! fakesink"

If you want to be sure that your video device works before going crazy with ARToolKit configuration try the next command:

gst-launch-0.10 v4l2src ! xvimagesink

If you want to use gst-launch-0.10 to try configurations of ARToolKit change fakesink for xvimagesink.

Once configured the ARTOOLKIT_CONFIG variable we can go to the bin folder of ARToolKit and run a test:

cd bin
./simpleTest

If V4L1 is used instead of GStreamer some video cameras don’t give a RGB picture, instead they send a YUV picture that ARToolKit doesn’t expect to receive. To fix this you have to configure the ARTOOLKIT_CONFIG environment variable with the palette option. You can see other V4L1 options in the official documentation.

-palette=YUV420P

Sources: http://www.block4.com/index.php?id=107

http://artoolkit.sourceforge.net/apidoc/video/#VideoLinuxV4L