Category Archives: Augmented Reality

ARSlides v1.0: Augmented Reality slide presentation application

I’m glad to inform that I’ve (finally) published the code for the Augmented Reality application I’ve been working. Here you can see a small demo of it (sorry for the low quality image):

This application can show images (JPG, GIF and also transparent PNG and TGA) and 3D models (DAE, 3DS, OSG, OBJ and FBX). You just have to write down the file paths of the files you want to show in the XML configuration file of the application and then use right key to move forward and left key to move backward. It can also show text with different colors and fonts but I still have to make some changes on the code to include this ability in the XML configuration file.

I’m currently adding video (AVI, MOV, etc.) and sound (WAV, MP3, etc.) file support and have had some success in the past with it, but problems with FFMpeg made the application crash randomly. Thats why I haven’t added this to the first version. I’ve created a new branch in Github with this so you can see how it’s being coded.

You can download the source code from this Github repository. And of course you can contribute to it! I would be very glad.

It uses ARToolKit, Collada-dom, OpenSceneGraph and osgART and in case you need some help installing them in your system you can use the installation scripts I made some time ago. There are also multiple installation guides in this blog where I explain the installation process.

Collada-dom 3D models having black textures bug solution

I used to have a problem with Collada-dom 3D models textures. Some times they were not correctly applied and appeared black colored. Just like in this case:

Some time ago I found out that this was related with the locale (the language) in which the Ubuntu system was configured. I usually use my Ubuntu in english and haven’t had any problem until one person lend me a Ubuntu laptop with spanish locale. I was all the weekend trying to figure what was going on (I didn’t get any error message so I was clue less) until I noticed that difference with my working system. I told to my colleague “I know what the problem is but don’t know how to solve, and we are out of time so just install Ubuntu in english”.

Today I made the mistake of installing the spanish locale along side with the english locale in order to have the calendars first day on monday, numbers and dates in spanish way and so on. Then… textures black. So I just uninstalled the spanish locale and though all would be OK again… but no… now the program crashed every time I tried to load a Collada-dom 3D model. But hey, this time I got an error on the console:

locale::facet::_S_create_c_locale name not valid

I could start digging with this! And found out that the problem is with the boost library. Depending on the version of your boost library (I’m using 1.46, and this is supposed to be fixed on 1.48) If the locale is not set to “C” it crashes.

So a quick fix is to export a LC_ALL environment variable to value C. You can do it permanent on your system configuring it on you profile file (in you home folder) or on a terminal just before running your program (in that same terminal of course) like this:

export LC_ALL=C

I use Eclipse-CDT to develop so the easiest way to configure this environment variable only for my application is using the Debug/Run Configurations. Click on the small arrow of the Degug or Run buttons and select “Debug Configurations…” or “Run Configurations…”. The got to the “Environment” tab and add the variable:

Hope this helps you because this has been a pain in the $%! for me! And this is how you should see now the 3D model:

UPDATE: Once I changed the locales I found out that when trying to install any package with apt-get a error was telling me that my locales were not correctly set:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "en_US:en",
        LC_ALL = (unset),
        LC_TIME = "es_ES.UTF-8",
        LC_MONETARY = "es_ES.UTF-8",
        LC_ADDRESS = "es_ES.UTF-8",
        LC_TELEPHONE = "es_ES.UTF-8",
        LC_NAME = "es_ES.UTF-8",
        LC_MEASUREMENT = "es_ES.UTF-8",
        LC_IDENTIFICATION = "es_ES.UTF-8",
        LC_NUMERIC = "es_ES.UTF-8",
        LC_PAPER = "es_ES.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory

As you can see my locales for time, monetary, address, telephone, name, measurement, identification, numeric and paper are in spanish (es_ES.UTF-8), my language is set up to english (es_US.UTF-8) and I have none set for LC_ALL. To fix this error I executed this on the terminal:

export LC_ALL=en_US.UTF-8
sudo locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales

And now the error is gone because all my locale variables are en_US.UTF-8. You can verify your locales running “locale”:

$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

Sources: https://svn.boost.org/trac/boost/ticket/4688
https://svn.boost.org/trac/boost/ticket/5928
http://www.becodemyfriend.com/2011/11/perl-warning-falling-back-to-the-standard-locale-%E2%80%9Cc%E2%80%9D/

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!

osgART 2.0 RC3 with OpenSceneGraph 2.9.7 or later (including 3.0.0)

Long time ago I had problems using osgART 2.0 RC3 with OpenSceneGraph 2.9.7 or later, I couldn’t get the video feed from the webcam on the background so I only used OpenSceneGraph 2.9.6. Today I found out that my osgART program could work with OpenSceneGraph 2.9.7 or later (current version 3.0.0 works too!), but as I always used 2.9.6 I didn’t know I have founded the solution to this problem!

NOTE: If you want to install OpenSceneGraph 3.0.0 in Ubuntu 11.10 or Ubuntu 12.04 you’ll have to use the patches I’ve created and uploaded to my github repository.

The key of the problem is that when you configure the video backgrounds osgART::VideoGeode you can use TEXTURE_2D or TEXTURE_RECTANGLE. If you use TEXTURE_RECTANGLE it will work on newer versions of OpenSceneGraph. You can look at line 40 of “examples/osgartsimple/osgartsimple.cpp” in osgART 2.0 RC3 source code folder:

osg::Group* createImageBackground(osg::Image* video) {
        osgART::VideoLayer* _layer = new osgART::VideoLayer();
        _layer->setSize(*video);
        osgART::VideoGeode* _geode = new osgART::VideoGeode(osgART::VideoGeode::USE_TEXTURE_2D, video);
        addTexturedQuad(*_geode,video->s(),video->t());
        _layer->addChild(_geode);
        return _layer;
}

If you installed OpenSceneGraph 2.9.7 or later and compiled osgART 2.0 RC3 as it comes in the original code, when you execute this example from “/usr/local/bin/osgartsimple” you will get this as you show the “Hiro” pattern to the camera:

If you change previous code this way:

osg::Group* createImageBackground(osg::Image* video) {
        osgART::VideoLayer* _layer = new osgART::VideoLayer();
        _layer->setSize(*video);
        osgART::VideoGeode* _geode = new osgART::VideoGeode(osgART::VideoGeode::USE_TEXTURE_RECTANGLE, video);
        addTexturedQuad(*_geode,video->s(),video->t());
        _layer->addChild(_geode);
        return _layer;
}

Then compile and install osgART 2.0 RC3 again, “/usr/local/bin/osgartsimple” will work OK.

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.

  • Page 1 of 2
  • 1
  • 2
  • >