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 "" -O ARToolKit-2.72.1.tgz
tar xzvpf ARToolKit-2.72.1.tgz
cd ARToolKit

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:


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
$ 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

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.



Install OpenCV 2.3.1a in Ubuntu 11.10

If you want to install OpenCV 2.1 you can just use apt-get to do the work:

sudo apt-get install libcv-dev libcv2.1 libcvaux-dev libcvaux2.1 libhighgui-dev libhighgui2.1 opencv-doc python-opencv

Some changes introduced in Ubuntu 11.10 causes OpenCV 2.3.1a not to compile because of ffmpeg. This makes the installation more complicated as we have to compile some libraries on our own. The other option would be just disabling ffmpeg in OpenCV with ccmake in WITH_FFMPEG option or using “-DWITH_FFMPEG=NO” with cmake.

First we have to uninstall some libraries:

sudo apt-get remove ffmpeg x264 libx264-dev

Get all the dependencies we need (run sudo apt-get update before this just in case):

sudo apt-get install build-essential checkinstall git cmake libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev texi2html yasm zlib1g-dev libtiff4-dev

Install gstreamer:

sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev gstreamer0.10-tools gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-dev gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg

Download, compile and install a stable and recent version of x264 (in my case it was x264-snapshot-20111213-2245-stable):

tar -xjvf last_stable_x264.tar.bz2
cd `ls -1d */ | grep x264-snapshot-`
./configure --enable-static
sudo make install

If you are compiling for x64 arquitecture it may be necessary to use the --enable-pic and --enable-shared option when running ./configure:

./configure --enable-static --enable-pic --enable-shared

Download, compile and install a 0.8.x version of ffmpeg (in my case it was 0.8.7) (for versions prior to OpenCV 2.3.1 use a 0.7.x version), although with versión 0.10.x works too:

tar -xjvf fmpeg-0.8.7.tar.bz2
cd ffmpeg-0.8.7
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
sudo make install

As it happend with x264 it may be necessary to use the –enable-pic and –enable-shared option when running ./configure:

./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-pic --enable-shared

Install gtk:

sudo apt-get install libgtk2.0-0 libgtk2.0-dev

Install libjpeg:

sudo apt-get install libjpeg62 libjpeg62-dev

Download, compile and install a 0.8.x version of v4l (in my case it was 0.8.5 but the, as of april 2012, 0.8.8 version works too):

tar -xjvf v4l-utils-0.8.5.tar.bz2
cd v4l-utils-0.8.5
sudo make install

Download, compile and install OpenCV 2.3.1a:

tar -xjvf OpenCV-2.3.1a.tar.bz2
cd OpenCV-2.3.1
mkdir build
cd build
cmake ..
sudo make install

Beyond this point you can look at how to install OpenCV in Ubuntu 10.10 for more configuration options of OpenCV installation.


Install OpenCV in Ubuntu 10.10

If you want to install OpenCV 2.1 you can just use apt-get to do the work:

sudo apt-get install libcv-dev libcv2.1 libcvaux-dev libcvaux2.1 libhighgui-dev libhighgui2.1 opencv-doc python-opencv

To install the latest stable version, which now is 2.3.1a, it’s necessary to compile the source code. We will need to install first some libraries and programs to be able to compile OpenCV:

sudo apt-get install cmake cmake-data cmake-curses-gui emacsen-common libxmlrpc-core-c3 g++ libv4l-dev libdc1394-22-dev libraw1394-dev libswscale-dev libavutil-dev libavformat-dev libavcodec-dev libjasper-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libgtk2.0-dev libtiff4-dev libopenexr-dev libunicap2-dev libeigen2-dev python-dev python-numpy libucil2 libucil2-dev

Now we download OpenCV 2.3.1a source code somewhere in our computer. I usually have a “compilations” directory in my home folder so everything is in place.


You could also download the from the SVN repository, but it may not be 2.3.1a compatible version. The stable version:

svn co

And the latest tested version:

svn co

After downloading the source code and extracting it we cd to the folder and execute:

mkdir build
cd build
cmake ..
sudo make install

This would configure and compile OpenCV with standard options, but we can change them by CMAKE parameters. For example to use the TBB (Threaring Building Blocks) it would be necessary to install them and activate that library when we execute cmake:

sudo apt-get install libtbb-dev libtbb2
cmake -D WITH_TBB=ON ..

OpenCV is configured by default to use CUDA (to use the GPU for some operations), but if we don’t have it installed you will see an error when configuring with cmake.

CUDA_TOOLKIT_ROOT_DIR not found or specified

To prevent this error (although it will compile without problems) just configure CUDA as OFF on cmake:

cmake -D WITH_CUDA=OFF ..

As you can se many options can be configured before compiling OpenCV. Look at this example and try to figure out what each one configures:


There is also a more visual way to configure all this options using ccmake (that why we installed cmake-curses-gui). If you run “ccmake ..” instead of “cmake ..” you will be presented with a ncurses user interface with many other options. If you want to see them all toggle to expert mode by pressing letter “t“. When you are ready with your options press “c” to configure (and see if there is any error or warning) and finish pressing “g” to generate the CMAKE files. Then you will be able to compile using “make” as ussual.

If you want to uninstall OpenCV go to your “build” folder and execute:

sudo make uninstall

If you get an error like this when running any OpenCV program:

error while loading shared libraries: cannot open shared object file: No such file or directory

You should create a file called “/etc/” and put inside the location of the folder with the OpenCV libraries, which should be /usr/local/lib/ (this is an option that can be changed during configuration with CMAKE_INSTALL_PREFIX option). Then reload the library configurations running this command:

sudo ldconfig /etc/

If you are using OpenCV 2.1 and have messages about “mmap invalid argument” running OpenCV programs, you will need to compile the source code but changing before the file “/src/highgui/cvcap_libv4l.cpp” on line 785 from:

mmap (NULL /* start anywhere */,


v4l2_mmap (NULL /* start anywhere */,

This bug is solved in SVN repository.