Here is brief description on how to build the latest version of OpenCV. See INSTALL file shipped with OpenCV for more detail. The required packages are listed below:
  • GCC 4.x or later. In Ubuntu/Debian it can be installed with
sudo apt-get install build-essential
  • CMake 2.6 or higher
  • Subversion (SVN) client
  • GTK+ 2.x or higher, including headers (e.g. libgtk2.0-dev)
  • pkgconfig
  • libpng, zlib, libjpeg, libtiff, libjasper with development files (e.g. libjpeg-dev)
  • Python 2.3 or later with developer packages (e.g. python-dev)
  • SWIG 1.3.30 or later
  • libavcodec etc. from ffmpeg 0.4.9-pre1 or later + headers. (Video support with FFMPEG)

  • libdc1394 2.x + headers for video capturing from IEEE1394 cameras

 

Getting OpenCV source code from the repository

Enter your working directory (denoted as ~/<your_working_dir> below) and type:

cd ~/<your_working_dir>
svn co https:
//opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/trunk


to get the current OpenCV snapshot, or

cd ~/<your_working_dir>
svn co https:
//opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/tags/latest_tested_snapshot

to get the latest tested OpenCV snapshot.

 

Compilation

To build OpenCV using cmake, type the following:


代码
cd ~/<your_working_dir>/opencv  # the directory should contain CMakeLists.txt, INSTALL etc.
mkdir release # create the output directory
cd release
cmake -D CMAKE_BUILD_TYPE
=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..


You will see the configuration results. Various build options can be adjusted interactively using CMake GUI. Then you build the library and install it to the target directory:

make
sudo make install

 

Path Configuration

In order to use the libraries in Linux, thier path should be specified. Library path can be specified in /etc/ld.so.conf.d/ by creating a file called 'opencv.conf' which contains the opencv library path (Default configuration is /usr/local/lib). Once the file is created, execute

sudo ldconfig -v

to make new set library pathes effective. Or you can also add the path to LD_LIBRARY_PATH:

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

 

Test OpenCV

You can run the correctness tests cxcoretest and cvtest for a quick sanity check:

cd ~/<your_working_dir>/opencv/release/bin
./cxcoretest
./cvtest -d ~/<your_working_dir>/opencv/tests/cv/testdata

You can also build and run OpenCV samples:

cd ~/<your_working_dir>/opencv/samples/c
. build_all.sh
./delaunay
# try other samples (some of them require a camera) ...
Posted on 2010-04-14 20:59  leivo  阅读(544)  评论(0编辑  收藏  举报