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
Hello,
thanks for the tutorial, it worked!
Hello,
I Have one question for you.
why in my bin folder in ARTOOLKIT, there was not simpleTest file ?
I’m not sure why that happend to you. (As far as I know) There is no option in ARToolKit to compile or not to compile the samples (as there is in OpenCV for example by using -D BUILD_EXAMPLES=ON with cmake). May be you could run the following to locate simpleTest on your system:
sudo updatedb
locate simpleTest
Hello,
./simpleTest don’t work with me too.
marco:~$ locate simpleTest
/home/marco/ARToolKit/examples/simple/simpleTest-Info.plist
/home/marco/ARToolKit/examples/simple/simpleTest.c
/home/marco/ARToolKit/examples/simple/simpleTest.dsp
/home/marco/ARToolKit/examples/simple/simpleTest.vcproj
/home/marco/ARToolKit/examples/simple2/simpleTest2-Info.plist
/home/marco/ARToolKit/examples/simple2/simpleTest2.c
/home/marco/ARToolKit/examples/simple2/simpleTest2.dsp
/home/marco/ARToolKit/examples/simple2/simpleTest2.vcproj
can you help me?
First run this “sudo updatedb” (updates de locate database) and then again “locate simpleTest” to see if the file really does not exists anywhere in your system.
If you don’t find the binary executable for simpleTest the problem must be that you didn’t compile it correctly. Look for any errors during configure or compile.
Hello!
I have a portable with a incorporated camera. In configuer, what should I choose? 1: V4L?
Thank you!
Built-in cameras as far as I know are internaly connected via USB so you could try with “5: GStreamer Media Framework” for USB webcams.”. If you only have one camera connected its device name should be /dev/video0
Hello!
I found the problem!
Was missing a opengl/glut libraries.
Now is working
thank you very much!!!
Thanks for such a great tutorial. It helped me finish my coding research just in time!
I try with option 1 and when i compile 2 errors occurred. appears a lib is missing.
In file included from ../../../include/AR/video.h:102:0,
from gsubUtil.c:19:
../../../include/AR/sys/videoLinuxV4L.h:24:30: fatal error: libv4l1-videodev.h: Ficheiro ou directoria inexistente
compilation terminated.
make[2]: *** [../../libARgsubUtil.a(gsubUtil.o)] Error 1
make[2]: Leaving directory `/home/marco/ARToolKit/lib/SRC/Gl’
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/marco/ARToolKit/lib/SRC’
make: *** [all] Error 2
marco:~/ARToolKit$
Thanks for posting this. I was able to get ARToolKit working on Linux Mint 13 Maya using these instructions.
Hi, im having an error on this command “sudo cp ./lib/*.a /usr/local/lib/”, the error: “cp: cannot stat ‘./lib/*.a’: No such file or directory”. Anyone can help?
Que tal, muy bueno el tutorial. Hice los pasos en Debian Wheezy y funciono. Ejecuto el ./simpleTest muestro la marca y aparece el cubo.
Ahora no se como ejecutar los otros ejemplos, como asocio una marca con el objeto que quiero que se vea?.
Espero que me aclares la interrogante y gracias nuevamente.
Saludos.
when i am trying to make am getting following error will u please say what is my mistake am following the steps as given by you
make[2]: *** [../../bin/videoTest] Error 1
make[2]: Leaving directory `/home/mlearn/ARToolKit/util/videoTest’
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/mlearn/ARToolKit/util’
make: *** [all] Error 2
after am selecting 5 option am getting following questions what should i give y or n please help in doing this
1.Do you want to create debug symbols? (y or n)
Build gsub libraries with texture rectangle support? (y or n)
2.GL_NV_texture_rectangle is supported on most NVidia graphics cards
and on ATi Radeon and better graphics cards
when am trying to run ./videoTest am getting following what to do next
ARVideo may be configured using one or more of the following options,
separated by a space:
DEVICE CONTROLS:
-dev=filepath
specifies device file.
-channel=N
specifies source channel.
-noadjust
prevent adjusting the width/height/channel if not suitable.
-width=N
specifies expected width of image.
-height=N
specifies expected height of image.
-palette=[RGB|YUV420P]
specifies the camera palette (WARNING:all are not supported on each camera !!).
IMAGE CONTROLS (WARNING: every options are not supported by all camera !!):
-brightness=N
specifies brightness. (0.0 1.0)
-contrast=N
specifies contrast. (0.0 1.0)
-saturation=N
specifies saturation (color). (0.0 1.0) (for color camera only)
-hue=N
specifies hue. (0.0 1.0) (for color camera only)
-whiteness=N
specifies whiteness. (0.0 1.0) (REMARK: gamma for some drivers, otherwise for greyscale camera only)
-color=N
specifies saturation (color). (0.0 1.0) (REMARK: obsolete !! use saturation control)
OPTION CONTROLS:
-mode=[PAL|NTSC|SECAM]
specifies TV signal mode (for tv/capture card).
You didn’t follow the instructions. You didn’t choose GStreamer (option 5) when you executed ./configure
here is what i exactly executed sir but getting the same problem any hekp fromur side
mlearn:~/ARToolKit$ ./Configure
Select a video capture driver.
1: Video4Linux
2: Video4Linux+JPEG Decompression (EyeToy)
3: Digital Video Camcoder through IEEE 1394 (DV Format)
4: Digital Video Camera through IEEE 1394 (VGA NONCOMPRESSED Image Format)
5: GStreamer Media Framework
Enter : 5
Do you want to create debug symbols? (y or n)
Enter : n
Build gsub libraries with texture rectangle support? (y or n)
GL_NV_texture_rectangle is supported on most NVidia graphics cards
and on ATi Radeon and better graphics cards
Enter : y
create ./Makefile
create lib/SRC/Makefile
create lib/SRC/AR/Makefile
create lib/SRC/ARMulti/Makefile
create lib/SRC/Gl/Makefile
create lib/SRC/VideoLinux1394Cam/Makefile
create lib/SRC/VideoLinuxDV/Makefile
create lib/SRC/VideoLinuxV4L/Makefile
create lib/SRC/VideoSGI/Makefile
create lib/SRC/VideoMacOSX/Makefile
create lib/SRC/VideoGStreamer/Makefile
create lib/SRC/ARvrml/Makefile
create util/Makefile
create util/calib_camera2/Makefile
create util/calib_cparam/Makefile
create util/calib_distortion/Makefile
create util/mk_patt/Makefile
create util/graphicsTest/Makefile
create util/videoTest/Makefile
create examples/Makefile
create examples/collide/Makefile
create examples/exview/Makefile
create examples/loadMultiple/Makefile
create examples/modeTest/Makefile
create examples/multi/Makefile
create examples/optical/Makefile
create examples/paddle/Makefile
create examples/paddleDemo/Makefile
create examples/paddleInteraction/Makefile
create examples/range/Makefile
create examples/relation/Makefile
create examples/simple/Makefile
create examples/simple2/Makefile
create examples/simpleLite/Makefile
create examples/twoView/Makefile
create examples/simpleVRML/Makefile
create include/AR/config.h
Done.
mlearn:~/ARToolKit$ make
collect2: ld returned 1 exit status
make[2]: *** [../../bin/videoTest] Error 1
make[2]: Leaving directory `/home/mlearn/ARToolKit/util/videoTest’
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/mlearn/ARToolKit/util’
make: *** [all] Error 2