Tag Archives: Collada

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 seted 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. Yo can verify your locales running “locale”:

$ locale

Sources: https://svn.boost.org/trac/boost/ticket/4688

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:


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!

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
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 “:


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/

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

Install OpenSceneGraph 2.9.6 with Collada support in Ubuntu 12.04

Although I usually install OpenSceneGraph 2.8.3 to work with osgART 2.0 RC3 it is also posible to use OpenSceneGraph 2.9.6 (in fact is the latests version compatible with osgART UPDATE: read this post to see how to make osgART 2.0 RC3 work with OpenSceneGraph 2.9.7 and further). You can download it using SVN:

svn checkout http://www.openscenegraph.org/svn/osg/OpenSceneGraph/tags/OpenSceneGraph-2.9.6 OpenSceneGraph-2.9.6

The steps to install OSG 2.9.6 with Collada support in Ubuntu 12.04 are just the same as I explained before in “Install OpenSceneGraph 2.8.3 with Collada support in Ubuntu 12.04“, but you have to do some more changes on the source code because of FFMpeg. So just add those changes to the source code of OSG 2.9.6 and then do just the same as if you were installing OSG 2.8.3:

- In line 276 change this:

const int bytes_decoded = avcodec_decode_audio2(m_context, reinterpret_cast(buffer), &data_size, m_packet_data, m_bytes_remaining);

To this:

            AVPacket avpkt;
            avpkt.data = const_cast(m_packet_data);
            avpkt.size = m_bytes_remaining;

            const int bytes_decoded = avcodec_decode_audio3(m_context, reinterpret_cast(buffer), &data_size, &avpkt);
            // fallback for older versions of ffmpeg that don't have avcodec_decode_audio3.
            const int bytes_decoded = avcodec_decode_audio2(m_context, reinterpret_cast(buffer), &data_size, m_packet_data, m_bytes_remaining);


- In line 168 change this:

const int bytes_decoded = avcodec_decode_video(m_context, m_frame.get(), &frame_finished, m_packet_data, m_bytes_remaining);

To this:

            AVPacket avpkt;
            avpkt.data = const_cast(m_packet_data);
            avpkt.size = m_bytes_remaining;

            const int bytes_decoded = avcodec_decode_video2(m_context, m_frame.get(), &frame_finished, &avpkt);
            // fallback for older versions of ffmpeg that don't have avcodec_decode_video2.
            const int bytes_decoded = avcodec_decode_video(m_context, m_frame.get(), &frame_finished, m_packet_data, m_bytes_remaining);

Sources: http://code.metager.de/source/xref/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp

Install OpenSceneGraph 2.8.3 with Collada support in Ubuntu 12.04

We are going to install OpenSceneGraph 2.8.3 (for now on OSG) to use it with osgART 2.0 RC3. As far as i know the last version of OSG that works with osgART is version 2.9.6 (following versions fail to draw the background video feed from the camera UPDATE: I found the solution to this error, read more in this post), but I recommend installing the 2.8.3 version. Download it from here and uncompress it.

Install those dependencies:

sudo apt-get install cmake cmake-curses-gui libopenal-dev libopenal1 libcurl4-openssl-dev libpoppler-dev libpoppler-glib-dev librsvg2-dev libgtkglext1 libgtkglext1-dev libgtkglextmm-x11-1.2-0 libgtkglextmm-x11-1.2-dev libwxgtk2.8-dev libopenthreads-dev libtiff4-dev libinventor0 inventor-dev libgif-dev libgif4 libjasper-dev libjasper1 libopenexr-dev libopenexr6 libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev libswscale-dev libavdevice53 libavcodec53 libavformat53 libavutil51 libswscale2 gstreamer0.10-ffmpeg ffmpeg libxine-dev libquicktime-dev winff dvdrip libavbin-dev libavbin0 libavifile-0.7c2 ffmpeg-dbg ffmpeg libavcodec-dev libavfilter-dev libxine1-ffmpeg moc-ffmpeg-plugin ffmpeg-dbg gstreamer0.10-fluendo-mp3 gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly libavbin-dev libavbin0 libavfilter-dev libavifile-0.7c2 libbabl-0.0-0 libcdaudio1 libmpeg2-4 libmpcdec6 libmp3lame0 libquicktime2 libxine1 libxine1-console libxine1-ffmpeg libxine1-misc-plugins libxine1-x moc-ffmpeg-plugin moc mjpegtools ogmtools xine-ui winff dvdrip libavbin-dev libavbin0 libavifile-0.7c2 ffmpeg-dbg ffmpeg-dbg ffmpeg libavcodec-dev libavfilter-dev libxine1-ffmpeg moc-ffmpeg-plugin

Install collada-dom as I explained in “Install collada-dom library in Ubuntu 10.04, 10.11, 11.04, 11.10 and 12.04“.

Some libraries that OSG depends on have changed so we need to change some of its source:

- Remove line 24 (#include ").
- Add the following include in line 2:


- Change CODEC_TYPE_AUDIO with AVMEDIA_TYPE_AUDIO on line 220.
- Change CODEC_TYPE_VIDEO with AVMEDIA_TYPE_VIDEO on line 238.
- Replace the content from lines 84 to 96 (a switch statement) with:

error_str = AVERROR(error);

- Add the following define bellow “#define __STDC_CONSTANT_MACROS“:


If you want to install OSG 2.9.6 add this changes to the source code too.

Now you can go inside your OSG 2.8.3 source code folder and run:

mkdir build
cd build
sudo make install

I added “-DCMAKE_CXX_FLAGS=-D__STDC_CONSTANT_MACROS” on cmake command to fix an error with UINT64_C definition. You can add “-DBUILD_OSG_EXAMPLES=1” to compile the examples (will be installed in “/usr/local/share/OpenSceneGraph/bin/“). If you do so download OpenSceneGraph-Data files too:

sudo svn checkout http://www.openscenegraph.org/svn/osg/OpenSceneGraph-Data/tags/OpenSceneGraph-Data-2.8.0/ /usr/local/share/OpenSceneGraph/OpenSceneGraph-Data

If you want to be sure that cmake finded the libraries from Collada, execute ccmake .. and verify that Collada library options are filled correctly:

COLLADA_BOOST_FILESYSTEM_LIBRA   /usr/lib/libboost_filesystem.so              
COLLADA_BOOST_SYSTEM_LIBRARY     /usr/lib/libboost_system.so                  
COLLADA_DOM_ROOT                 /dom                                         
COLLADA_DYNAMIC_LIBRARY          /usr/local/lib/libcollada14dom.so            
COLLADA_INCLUDE_DIR              /usr/local/include/colladadom                 
COLLADA_MINIZIP_LIBRARY          /usr/local/lib/libminizip.so                 
COLLADA_PCRECPP_LIBRARY          /usr/lib/i386-linux-gnu/libpcrecpp.so        
COLLADA_PCRE_LIBRARY             /usr/lib/i386-linux-gnu/libpcre.so           

When you finish compiling and installing OSG you should have a file called “osgdb_dae.so” in your OSG plugins folder (“/usr/local/lib/osgPlugins-2.8.3“). If you don’t have it verify you installed correctly the collada-dom library and that OSG is configured to use it.

Add the /usr/local/lib and /usr/local/lib/osgPlugins-2.8.3 library folders to the LD_LIBRARY_PATH variable on ~/.bashrc or ~/.profile:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib/osgPlugins-2.8.3

If you downloaded the OpenSceneGraph-Data files add the following too:

export OSG_FILE_PATH=/usr/local/share/OpenSceneGraph/OpenSceneGraph-Data

You can test if OSG work correctly by executing one of the examples (if you compiled them of course):


You should see something like this:

  • Page 1 of 2
  • 1
  • 2
  • >