Thursday, August 13, 2009

How to download & compile the latest OpenCV

Once you have your environment set up you will be able to download and compile OpenCV to your Linux environment easily. Some Linux distributions are easier than other to setup. Sabayon is one such distro that comes with many of the necessary packages already installed.

Execute the following commands:
  1. mkdir opencv
  2. svn co https://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/trunk opencv
  3. cd opencv/opencv
  4. mkdir release
  5. cd release
  6. sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ../
Now make sure everything worked and was found. If you get errors you need to fix them now or else you will have issues completing a successful install.

Execute the following:

  1. sudo make
  2. sudo make install

If everything goes as planned OpenCV should compile successfully (100% during the make). If not check your libraries and if all else fails try getting the code from the SVN again.

There it is, you have installed OpenCV from source!

Update #1:
   If you receive the error from cxcorr.hpp indicating that ptrdiff_t does not name a type, please add this line of code to cxcorr.hpp (as indicated by stackoverflow.com):

  1. #include <stddef.h>

No comments:

Post a Comment