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.
Get the executable installation from SourceForge and run it. It will install OpenCV, register DirectShow filters, and perform various post-installation procedures. You are now ready to start using OpenCV. You can always go to the …/opencv/_make directory and open opencv.sln with MSVC++ or MSVC.NET 2005, or you can open opencv.dsw with lower versions of MSVC++ and build debug versions or rebuild release versions of the library.[5]
To add the commercial IPP performance optimizations to Windows, obtain and install IPP from the Intel site (http://www.intel.com/software/products/ipp/index.htm); use version 5.1 or later. Make sure the appropriate binary folder (e.g., c:/program files/intel/ipp/5.1/ia32/bin) is in the system path. IPP should now be automatically detected by OpenCV and loaded at runtime (more on this in Chapter 3).
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.
As of this writing, full functionality on MacOS X is a priority but there are still some limitations (e.g., writing AVIs); these limitations are described in …/opencv/INSTALL.
The requirements and building instructions are similar to the Linux case, with the following exceptions:
By default, Carbon is used instead of GTK+.
By default, QuickTime is used instead of ffmpeg.
pkg-config is optional (it is used explicitly only in the samples/c/build_all.sh script).
RPM and ldconfig are not supported by default. Use
configure+make+sudo make install
to build and install OpenCV, updateDYLD_LIBRARY_PATH
(unless./configure --prefix=/usr
is used).
For full functionality, you should install libpng,
libtiff, libjpeg and libjasper from
darwinports and/or fink and make them available to ./configure (see ./configure --help
).
For the most current information, see the OpenCV Wiki at http://opencvlibrary.SourceForge.net/ and the Mac-specific page http://opencvlibrary.SourceForge.net/Mac_OS_X_OpenCV_Port.
[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
.
Get Learning OpenCV now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.