Dienstag, 26. März 2013

OpenCV 2.4.2 on Dreamplug

Because of some real-time image processing I want to use OpenCV on the dreamplug. As expected, there is no precompiled package available for the dreamplug.

I chose 2.4.2 because I worked with this version for half a year and I'm pretty sure to run into no unexpected bugs this way.

To get a good overview on how to build OpenCV from source, refer http://opencv.willowgarage.com/wiki/InstallGuide

1.) Create a workspace (temporary folder) and download the OpenCV-Sources from  Sourceforge:

 mkdir /tmp/opencv  
 cd /tmp/opencv  
 wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.2/OpenCV-2.4.2.tar.bz2/download  

2.) This leaves you with a 52MB file called 'download'. As it was formerly a tar.bz2 archive, let us get things right;

 mv download OpenCV-2.4.2.tar.bz2  

3.) Now unpack the whole thing

 root@debian:/tmp/opencv# tar -xvf OpenCV-2.4.2.tar.bz2  

4.) Once this is done you got an Folder named OpenCV-2.4.2.tar.bz2. This one holds the complete source code of opencv. In order to build the source, cMake has to be installed. If this is not the case on your dreamplug, install it by typing

 root@debian:/tmp/opencv# apt-get install cmake  

Well, now comes the funny part. Debian repositories for Dreamplug do NOT include a acceptable up-to-date version of cmake. So make sure to check the Version with cmake --version. If not the latest version of CMake is used, the build of OpenCV fails!! Lucky as I am this was the case at my dreamplug. Of course also the prebuilt stuff from CMake does not work, so I had to build that thing from source as well. Source is available at www.cmake.org/files/v2.8/cmake- Simply download, un-tar and follow the instructions in Readme.txt. Note this step here takes forever and longer...

5.) Now make sure everything you need to build is installed. I got this from http://opencv.willowgarage.com/wiki/InstallGuide%20%3A%20Debian
It says not all packages are needed but I'm too lazy by now to sort out which ones I need and which ones not. Most likely the python stuff and everything related to GUI is not needed. Some may notify that cmake is listed again ;) Also the freeglut-stuff is most likely redundant as long as you don't want to use OpenGL.

 apt-get install build-essential 
 apt-get install pkg-config  
 apt-get install libpng12-0 libpng12-dev libpng++-dev libpng3  
 apt-get install libpnglite-dev libpngwriter0-dev libpngwriter0c2  
 apt-get install zlib1g-dbg zlib1g zlib1g-dev  
 apt-get install libjasper-dev libjasper-runtime libjasper1  
 apt-get install pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools  
 apt-get install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-prog  
 apt-get install ffmpeg libavcodec-dev libavcodec52 libavformat52 libavformat-dev  
 apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev  
 apt-get install libxine1-ffmpeg libxine-dev libxine1-bin  
 apt-get install libunicap2 libunicap2-dev  
 apt-get install libdc1394-22-dev libdc1394-22 libdc1394-utils  
 apt-get install swig  
 apt-get install libv4l-0 libv4l-dev  
 apt-get install python-numpy  

 5.) Now let's run cmake. This creates a makefile and some other stuff required for building the library. cmake performs a bunch of tests to make sure the following build has chances to be sucessful.

6.) As we're building for a release version, let's create a directory and run cmake in ther. Note that I left out Python support here!

  root@debian:/tmp/opencv# mkdir release  
  root@debian:/tmp/opencv# cd release  
  root@debian:/tmp/opencv/release# cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ../OpenCV-2.4.2  

7.) Now comes the busy part. Simply run 'make' and grap a cup of coffee - this takes a while.

 root@debian:/tmp/opencv# make  

8.) A night later type the following:

 root@debian:/tmp/opencv# make install  

This should install OpenCV to /usr/local (becase this was passed as install prefix to cmake, see  above). Afterwards OpenCV should be available on your dreamplug. To verify, compile the following program:

Keine Kommentare:

Kommentar veröffentlichen