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
1 Comments.