Math routines for image processing,
computer vision, and image
OpenCV includes math commonly
used, algorithms from linear algebra,
statistics, and computational geometry.
FIGURE 2. Selecting
OpenCV header files
in Windows to place
into a single include
These interfaces let you write text
and draw on images. In addition to various fun and creative possibilities, these
functions are useful for labeling and marking. For example, if you write a program
that detects objects, it’s helpful to label
images with their sizes and locations.
However, the simplest interfaces for
face recognition are
in this module. The
code behind them is
specialized for face
they’re widely used
for that purpose.
OpenCV includes its own windowing interfaces. While these are limited
compared to what can be done on
each platform, they provide a simple,
multi-platform API to display images,
accept user input via mouse or keyboard, and implement slider controls.
Datastructures and algorithms
With these interfaces, you can
efficiently store, search, save, and
manipulate large lists, collections (also
called sets), graphs, and trees.
These methods provide convenient
interfaces for storing various types of
data to disk and retrieving them later.
Figure 1 shows a few examples of
OpenCV’s capabilities in action: face
detection, contour detection, and edge
OpenCV’s functionality is contained in several modules.
CXCORE contains basic datatype
definitions. For example, the data
structures for image, point, and rectangle are defined in cxtypes.h. CXCORE
also contains linear algebra and statistics methods, the persistence functions, and error handlers. Somewhat
oddly, the graphics functions for drawing on images are located here, as well.
CV contains image processing and
camera calibration methods. The
computational geometry functions are
also located here.
CVAUX is described in OpenCV’s documentation as containing obsolete and
ML contains machine-learning
The remaining functionality is contained in HighGUI and CVCAM. Both of
these are located in a directory named
“otherlibs,” making them easy to miss.
Since HighGUI contains the basic I/O
interfaces, you’ll want to be sure you
don’t overlook it! It also contains the
multi-platform windowing capabilities.
CVCAM contains interfaces for
video access through DirectX on 32-bit
Windows platforms. However, HighGUI
also contains video interfaces. In this
article, I’ll cover only the interfaces in
HighGUI. They’re simpler to use, and
they work on all platforms. If you’re
using Windows XP or 2000, you may
get a performance boost by switching
to the CVCAM interfaces, but for
learning OpenCV, the simpler ones in
HighGUI are just fine.
OpenCV for Linux or MacOSX is
packaged as a source-code archive.
You’ll need to build both static and
shared-object libraries. You can either
build an RPM first and install from that,
or compile and install it directly.
Instructions for doing both are in
The Windows download is packaged as an executable that installs
OpenCV when you run it. It places
OpenCV files into a directory of your
choice, optionally modifies your system
path to include the OpenCV binaries,
and registers several DirectX filters. By
default, it installs to C:/Program
Customizing a Windows Install
For Windows users, OpenCV is
easy to install, and the default installation will work. But a bit of advance
planning may leave you happier with
the results. Here are a few suggestions.
Since OpenCV is a developers’
toolkit — not a program — you may
want to locate it somewhere other
than your Program Files directory. If
you do prefer to locate it elsewhere,
decide that before you run the installer,
and enter that location when asked.
I suggest you also decide — before
installing — how you want Windows to
find the OpenCV dlls. You can either
modify your system’s PATH variable to
include their location, or you can move
them, after installing, from OpenCV’s
“bin” directory to your SYSTEM_ROOT
If you prefer to move the dlls, but
aren’t sure where your SYSTEM_ROOT
directory is, you can locate it by
running the sysinfo utility available at
If you prefer to modify the PATH
rather than moving the dlls, you can
have the installer do that for you
by selecting the check box “Add bin
directory to PATH.”
The OpenCV directory contains
several subdirectories. The docs directory contains html documentation for all
the OpenCV functions and datatypes.
Since the best documentation is a
working example, you might also want
to browse the “samples” directory.
The header files you’ll need to
include when you compile programs that
use OpenCV are distributed among the
SERVO 01.2007 63