Tag Archives: Ubuntu - Page 2

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:

/src/osgPlugins/curl/ReaderWriterCURL.cpp
- Remove line 24 (#include ").
/src/osgPlugins/ffmpeg/FFmpegDecoder.cpp
- Add the following include in line 2:

#include 

- 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);

/src/osgPlugins/ffmpeg/FFmpegHeaders.hpp
- Add the following define bellow “#define __STDC_CONSTANT_MACROS“:

#define FF_API_OLD_SAMPLE_FMT 0

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
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-D__STDC_CONSTANT_MACROS
make
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_FILESYSTEM_LIBRA   COLLADA_BOOST_FILESYSTEM_LIBRARY_DEBUG-NOTFOU
COLLADA_BOOST_SYSTEM_LIBRARY     /usr/lib/libboost_system.so                  
COLLADA_BOOST_SYSTEM_LIBRARY_D   COLLADA_BOOST_SYSTEM_LIBRARY_DEBUG-NOTFOUND  
COLLADA_DOM_ROOT                 /dom                                         
COLLADA_DYNAMIC_LIBRARY          /usr/local/lib/libcollada14dom.so            
COLLADA_DYNAMIC_LIBRARY_DEBUG    COLLADA_DYNAMIC_LIBRARY_DEBUG-NOTFOUND       
COLLADA_INCLUDE_DIR              /usr/local/include/colladadom                 
COLLADA_MINIZIP_LIBRARY          /usr/local/lib/libminizip.so                 
COLLADA_MINIZIP_LIBRARY_DEBUG    COLLADA_MINIZIP_LIBRARY_DEBUG-NOTFOUND       
COLLADA_PCRECPP_LIBRARY          /usr/lib/i386-linux-gnu/libpcrecpp.so        
COLLADA_PCRECPP_LIBRARY_DEBUG    COLLADA_PCRECPP_LIBRARY_DEBUG-NOTFOUND       
COLLADA_PCRE_LIBRARY             /usr/lib/i386-linux-gnu/libpcre.so           
COLLADA_PCRE_LIBRARY_DEBUG       COLLADA_PCRE_LIBRARY_DEBUG-NOTFOUND          
COLLADA_STATIC_LIBRARY           COLLADA_STATIC_LIBRARY-NOTFOUND              
COLLADA_STATIC_LIBRARY_DEBUG     COLLADA_STATIC_LIBRARY_DEBUG-NOTFOUND 

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

/usr/local/share/OpenSceneGraph/bin/osglogo

You should see something like this:

Install collada-dom library in Ubuntu 10.04, 10.11, 11.04, 11.10 and 12.04

I wanted to install collada-dom to add support for DAE files on OpenSceneGraph. I used the SVN from 2011/03/12 (I already had it downloaded and knew it worked fine). You can download the same code for that date with this commnad:

svn co -r {20110312} https://collada-dom.svn.sourceforge.net/svnroot/collada-dom/trunk collada-dom

The last trunk code in SVN repository fails to compile rt and fx projects and even does not work with OpenSceneGraph (looks like some types disapeared from Collada DOM and OpenSceneGraph plugin for DAE files expects them). Anyway if you want to try you can download running this command:

svn co https://collada-dom.svn.sourceforge.net/svnroot/collada-dom/trunk collada-dom

Install the following dependencies for Ubuntu 10.04:

sudo apt-get install libboost1.40-dev libpcre++-dev nvidia-cg-toolkit libboost-filesystem1.40-dev libglut3-dev

For Ubuntu 10.10 and 11.04 install those:

sudo apt-get install libboost1.42-dev libpcre++-dev nvidia-cg-toolkit libboost-filesystem1.42-dev libglut3-dev

And for Ubuntu 11.10 and 12.04 install those:

sudo apt-get install libboost1.46-dev libpcre++-dev nvidia-cg-toolkit libboost-filesystem1.46-dev freeglut3-dev

To compile execute, inside the collada-dom folder, those commands:

make os=linux project=minizip -C dom
make os=linux project=dom -C dom
make os=linux project=rt -C rt
make os=linux project=fx -C fx

We can now just copy the libraries and includes we need to “/usr/local/lib” and “/usr/local/include“:

sudo cp dom/build/linux-1.4/libminizip.* /usr/local/lib/
sudo cp dom/build/linux-1.4/libcollada14dom.* /usr/local/lib/
sudo cp -R dom/include /usr/local/include/colladadom
sudo cp rt/build/linux-1.4/libcollada14rt.* /usr/local/lib/
sudo cp fx/build/linux-1.4/libcollada14fx.* /usr/local/lib/

UPDATE: Fixed the compilation and installation process to bypass the problems with domTest and viewer. Also excluded rt and fx because they are not necessary. Ignore rest of the post.

But there have been some changes in the Boost library used in Ubuntu 12.04: the function native_file_string() has been deleted and we have to change “dom/test/1.4/domTest.cpp” file code on lines 91 and 95 to call c_str() instead of native_file_string(). So change this:

string lookupTestFile(const string& fileName) {
        return (dataPath() / fileName).native_file_string();
}

string getTmpFile(const string& fileName) {
        return (tmpPath() / fileName).native_file_string();
}

To this:

string lookupTestFile(const string& fileName) {
        return (dataPath() / fileName).c_str();
}

string getTmpFile(const string& fileName) {
        return (tmpPath() / fileName).c_str();
}

I got another error while compiling domTest complaining about not being able to locate a reference to libboost_system:

make[1]: Entering directory `/home/user/compilations/collada-dom/dom'
Linking build/linux-1.4/domTest
/usr/bin/ld: build/linux-1.4/obj/domTest.o: undefined reference to symbol 'boost::system::system_category()'
/usr/bin/ld: note: 'boost::system::system_category()' is defined in DSO /usr/lib/libboost_system.so.1.46.1 so try adding it to the linker command line
/usr/lib/libboost_system.so.1.46.1: could not read symbols: Invalid operation

I added -lboost_system -lboost_filesystem to the libOpts variable in “dom/make/common.mk” file (line 25) and it worked.

libOpts := -lboost_system -l boost_filesystem

I also had a similar error while compiling the “viewer” library, but we don’t need this.

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

Use OpenCV in Eclipse CDT

Install OpenCV (see previous posts for Ubuntu 10.10, Ubuntu 11.10, Ubuntu 12.04 and OpenCV 2.4 in Ubuntu 12.04).

Install Eclipse CDT:

sudo apt-get install eclipse-cdt

Open Eclipse CDT and select a workspace (it’s just a path to store projects together). Create a new “C++ Project”, give it a name and select “Empty Project” on “Project type” and “Linux GCC” on “Toolchains”.

Right click on the project folder and select “Properties”. Go to “C/C++ Build->Settings”. Then, inside “Tool Settings” tab, go to “GCC C++ Compiler->Includes” and fill “Include paths (-l)” with the path of your OpenCV include installation. If you installed OpenCV from the source code it will possibly be “/usr/local/include/opencv2” (or the path you entered in CMAKE_INSTALL_PREFIX when configuring with CMake), but if you installed from the repositories it should be “/usr/include/opencv2“.

Now go to “GCC C++ Linker->Libraries” and fill “Libraries (-l)” with (at least) those OpenCV libraries:

opencv_core
opencv_highgui

And “Library search paths (-L)” with the path location of your OpenCV installation libraries. As before, if you installed from the source it should be “/usr/local/lib” (same here with CMAKE_INSTALL_PREFIX) and if you installed with repositories “/usr/lib“.

Now it’s time to code. Go to “File->New->Source file” and create a new file called “main.cpp“. Fill it with:

#include "opencv.hpp"

int main(int argc, char* argv[])  {

        IplImage* img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 3 );

        cvCircle( img, cvPoint( 320, 240 ), 100, cvScalar( 255, 0, 0 ), 5 );

        cvNamedWindow( "OpenCV Window", CV_WINDOW_NORMAL );
        cvShowImage( "OpenCV Window", img );

        cvWaitKey(0);

        cvDestroyWindow( "OpenCV Window" );
        cvReleaseImage( &img );

        return 0;
}

This code will just show a black window with a blue circle in it and end when you press any key. Not very fancy but we just want to check if all runs OK.

Eclipse CDT comes with an option to build automatically, but I always disable it deselecting “Project->Build Automatically”. Build all by pressing Control+B or going to “Project->Build All”. Before debugging/running our application we need to configure the debugging/running environment. Go to “Run->Debug Configurations…” and do a double click on “C/C++ Application”. It will create a new debug configuration, but “C/C++ Application” parameter may not be automatically configured (this happend to me), so use “Browse…” button to select a “Project”, select your current project, and now (if your application binary program does exist) all should be OK to push “Debug” button.

You should now be able to run and debug your OpenCV application. Using any other library with Eclipse CDT is pretty much the same.

Install OpenCV 2.4 in Ubuntu 12.04

Installing OpenCV 2.4 from source code as I did with OpenCV 2.3.1a in Ubuntu 10.10 went flawlessly, didn’t need changing any of the preexisting ffmpeg libraries as I had to in Ubuntu 11.10.

You can download the source code for it from here.

But be aware of the changes in new version. If you are updating from a previous version of OpenCV be careful because they have introduced multiple changes and your code might not work. This are some of the biggest changes:

  • OpenCV now provides pretty complete build information via (surprise) cv::getBuildInformation().
  • reading/writing video via ffmpeg finally works and it’s now available on MacOSX too.
  • MOG2 background subtraction by Zoran Zivkovic was optimized using TBB.
  • >20 more bugs in our bug tracker have been closed (http://code.opencv.org/projects/opencv/roadmap).
  • Asus Xtion is now properly supported for HighGUI. For now, you have to manually specify this device by using VideoCapture(CV_CAP_OPENNI_ASUS) instead of VideoCapture(CV_CAP_OPENNI).
  • Some of the old functionality from the modules imgproc, video, calib3d, features2d, objdetect has been moved to legacy.
  • CMake scripts have been substantially modified. Now it’s very easy to add new modules – just put the directory with include, src, doc and test sub-directories to the modules directory, create a very simple CMakeLists.txt and your module will be built as a part of OpenCV. Also, it’s possible to exclude certain modules from build (the CMake variables “BUILD_opencv_” control that).
  • The new very base cv::Algorithm class has been introduced. It’s planned to be the base of all the “non-trivial” OpenCV functionality.
  • features2d API has been cleaned up. There are no more numerous classes with duplicated functionality. The base classes FeatureDetector and DescriptorExtractor are now derivatives of cv::Algorithm. There is also the base Feature2D, using which you can detect keypoints and compute the descriptors in a single call. This is also more efficient.
  • SIFT and SURF have been moved to a separate module named nonfree to indicate possible legal issues of using those algorithms in user applications. Also, SIFT performance has been substantially improved (by factor of 3-4x).
  • The current state-of-art textureless detection algorithm, Line-Mod by S. Hinterstoisser, has been contributed by Patrick Mihelich. See objdetect/objdetect.hpp, class Detector.
  • 3 face recognition algorithms have been contributed by Philipp Wagner. Please, check opencv/contrib/contrib.hpp, FaceRecognizer class, and opencv/samples/cpp/facerec_demo.cpp.
  • 2 algorithms for solving PnP problem have been added. Please, check flags parameter in solvePnP and solvePnPRansac functions.
  • Enhanced LogPolar implementation (that uses Blind-Spot model) has been contributed by Fabio Solari and Manuela Chessa, see opencv/contrib/contrib.hpp, LogPolar_* classes and opencv/samples/cpp/logpolar_bsm.cpp sample.
  • A stub module photo has been created to support a quickly growing “computational photography” area. Currently, it only contains inpainting algorithm, moved from imgproc, but it’s planned to add much more functionality.
  • Another module videostab (beta version) has been added that solves a specific yet very important task of video stabilization. The module is under active development. Please, check opencv/samples/cpp/videostab.cpp sample.
  • findContours can now find contours on a 32-bit integer image of labels (not only on a black-and-white 8-bit image). This is a step towards more convenient connected component analysis.
  • Canny edge detector can now be run on color images, which results in better edge maps.

Source of changelog: Computer vision talks.

  • Page 2 of 3
  • <
  • 1
  • 2
  • 3
  • >