Downloading and Installing OpenCV

The main OpenCV site is on SourceForge at http://SourceForge.net/projects/opencvlibrary and the OpenCV Wiki [OpenCV Wiki] page is at http://opencvlibrary.SourceForge.net. For Linux, the source distribution is the file opencv-1.0.0.tar.gz; for Windows, you want OpenCV_1.0.exe. However, the most up-to-date version is always on the CVS server at SourceForge.

Once you download the libraries, you must install them. For detailed installation instructions on Linux or Mac OS, see the text file named INSTALL directly under the …/opencv/ directory; this file also describes how to build and run the OpenCV testing routines. INSTALL lists the additional programs you'll need in order to become an OpenCV developer, such as autoconf, automake, libtool, and swig.

Prebuilt binaries for Linux are not included with the Linux version of OpenCV owing to the large variety of versions of GCC and GLIBC in different distributions (SuSE, Debian, Ubuntu, etc.). If your distribution doesn't offer OpenCV, you'll have to build it from sources as detailed in the …/opencv/INSTALL file.

To build the libraries and demos, you'll need GTK+ 2.x or higher, including headers. You'll also need pkgconfig, libpng, zlib, libjpeg, libtiff, and libjasper with development files. You'll need Python 2.3, 2.4, or 2.5 with headers installed (developer package). You will also need libavcodec and the other libav* libraries (including headers) from ffmpeg 0.4.9-pre1 or later (svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg).

Download ffmpeg from http://ffmpeg.mplayerhq.hu/download.html.[6] The ffmpeg program has a lesser general public license (LGPL). To use it with non-GPL software (such as OpenCV), build and use a shared ffmpg library:

$> ./configure --enable-shared
$> make
$> sudo make install

You will end up with: /usr/local/lib/libavcodec.so.*, /usr/local/lib/libavformat.so.*, /usr/local/lib/libavutil.so.*, and include files under various /usr/local/include/libav*.

To build OpenCV once it is downloaded:[7]

$> ./configure
$> make
$> sudo make install
$> sudo ldconfig

After installation is complete, the default installation path is /usr/local/lib/ and /usr/local/include/opencv/. Hence you need to add /usr/local/lib/ to /etc/ld.so.conf (and run ldconfig afterwards) or add it to the LD_LIBRARY_PATH environment variable; then you are done.

To add the commercial IPP performance optimizations to Linux, install IPP as described previously. Let's assume it was installed in /opt/intel/ipp/5.1/ia32/. Add <your install_path>/bin/ and <your install_path>/bin/linux32 LD_LIBRARY_PATH in your initialization script (.bashrc or similar):

LD_LIBRARY_PATH=/opt/intel/ipp/5.1/ia32/bin:/opt/intel/ipp/5.1
/ia32/bin/linux32:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

Alternatively, you can add <your install_path>/bin and <your install_path>/bin/linux32, one per line, to /etc/ld.so.conf and then run ldconfig as root (or use sudo).

That's it. Now OpenCV should be able to locate IPP shared libraries and make use of them on Linux. See …/opencv/INSTALL for more details.



[5] It is important to know that, although the Windows distribution contains binary libraries for release builds, it does not contain the debug builds of these libraries. It is therefore likely that, before developing with OpenCV, you will want to open the solution file and build these libraries for yourself.

[6] You can check out ffmpeg by: svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg.

[7] To build OpenCV using Red Hat Package Managers (RPMs), use rpmbuild -ta OpenCV-x.y.z.tar.gz (for RPM 4.x or later), or rpm -ta OpenCV-x.y.z.tar.gz (for earlier versions of RPM), where OpenCV-x.y.z.tar.gz should be put in /usr/src/redhat/SOURCES/ or a similar directory. Then install OpenCV using rpm -i OpenCV-x.y.z.*.rpm.