Category Archives: Augmented Reality - Page 2

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

  • Page 2 of 2
  • <
  • 1
  • 2