Installing OpenCV on Linux

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:

sudo apt-get install build-essential

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/cv

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

OpenCVWiki: InstallGuide_Linux (last edited 2010-03-04 19:52:54 by DanFarmer)