Combined, the books' English editions alone have sold more than 13,000
copies, representing a goodly crowd of computer vision students and
professionals. If you are already a reader, thank you! If not, please consider becoming
one. Together, we are learning to see the world through a new set of lenses.

On this page, you can download installers and source code that will help you complete
the OpenCV projects described in the books and presentations. This site is also the right
place to check for FAQ, errata, and updates.

Which Book is Right for You?

The following comparison table may help you choose the next book to
read:

Title

Platforms

Languages

Level

OpenCV for Secret Agents

Windows, Mac, Linux, Raspberry Pi, Android, Unity

Python, Java, C#

Intermediate to Advanced

OpenCV 3 Blueprints

Windows, Mac, Linux, Android

C++, Python, Java

Advanced

iOS Application Development with OpenCV 3

iOS

Objective-C, C++

Beginning and Up

Android Application Programming with OpenCV 3

Android

Java, C++

Beginning and Up

Learning OpenCV 3 Computer Vision with Python

Windows, Mac, Linux

Python

Beginning and Up

Python Game Programming by Example

Windows, Mac, Linux

Python

Beginning and Up

Bear in mind that my books focus on computer vision, application
development, and game development, rather than programming languages per
se. If you are unfamiliar with a language, you may want to find a
general-purpose guide to the language, too.

OpenCV for Secret Agents

This book's English edition (January 2015) is titled OpenCV for
Secret Agents.

OpenCV项目开发实战
(September 2016) is a Simplified Chinese translation of the book. The
English-language downloads and FAQ in this section might also help readers of
OpenCV项目开发实战, but for
Chinese-language support please visit
Tsinghua
University Press.

For OpenCV 3.x, Chapter 3 depends on the face module from
opencv_contrib.
(Follow the preceding link to find instructions on building OpenCV
from source with opencv_contrib. Alternatively, on Mac with MacPorts,
install the opencv package with the +contrib variant.) For OpenCV
2.4.x, opencv_contrib is not required.

FAQ

Q. Which OpenCV versions does the book support?

A. Originally, the book targets OpenCV 2.4.x. The source
code downloads have been updated to support both OpenCV 2.4.x and OpenCV
3.x (together in one download per chapter). For the Python projects, a script
called CVForwardCompat.py simply creates aliases to give OpenCV 3.x
functionality the same names as equivalent OpenCV 2.4.x functionality.

Errata and Updates

Improved cat face cascades with lower false positive rate

I have trained new versions of the cat face cascades with more negative
samples and more stages. False positives are much rarer now. If you tailored
your code for the cascade's previous version, now you should re-adjust the
arguments of CascadeClassifier::detectMultiScale. For example, decrease the
value of the minNeighbors argument. The book's source code download for
Chapter 3 has been updated to train and use the new cascades.

You do not need to use a human face detector to cross-check the positives
anymore. However, the source code download still contains an example of how to
do this (in case you want to be extra cautious).

For further information on the new cascades, see the
merge request where
the cascades have been merged into OpenCV.

Finding the VOC2007 dataset and VOC2007 website

The VOC2007 dataset and website are no longer available at the URLs listed
in the book. Instead, use the University of Texas
mirror of the VOC2007
dataset. The book's source code download for Chapter 3 has been updated to
use this mirror in the cascade_training/download_datasets.sh script.

Finding the Microsoft Cat Dataset 2008

The Microsoft Cat Dataset 2008 and its website are no longer available at
the URLs listed in the book. Instead, use the Internet Archive Wayback Machine's
mirror
of the site, which includes downloads of
Part
1 and Part
2 of the dataset. The book's source code download for Chapter 3 has been
updated to use this mirror in the cascade_training/download_datasets.sh
script.

Setting and validating the camera's image dimensions

On page 85, the implementation of the cvResizeCapture function has problems
with some cameras and some builds of OpenCV. It may fail to return the camera's
actual image dimensions. The following implementation is more robust:

Note that in the updated implementation, we do not check the Boolean
returned by capture.set because its value might not accurately reflect success;
it may be true even if the requested image dimensions could not be set.
Instead, we always check the actual image dimensions using capture.get.

Even the updated implementation is not foolproof. For example, buggy camera
drivers could report inaccurate dimensions via capture.get or could capture
incomplete images (with fewer rows than normal) at the start of a stream. To be
absolutely sure of an image's dimensions, capture the image first and then
check its dimensions. Remember, in OpenCV's Python API, the image is a NumPy
array and you can check its dimensions via its shape attribute.

The downloadable source code contains the updated implementation.

Update to Bing Search API

Microsoft has discontinued support for Azure Data Market, which includes
Bing Search API v2. As a replacement, Microsoft has introduced Cognitive
Services, which includes Bing Search API v5. The book's source code download
for Chapter 2 has been updated to use Bing Search API v5 via a third-party
Python wrapper called py-ms-cognitive. A version of py-ms-cognitive is
included with the chapter's code, or you can find the latest version on the
py-ms-cognitive GitHub repository.

After you download the chapter's code, edit ImageSearchSession.py to
replace the value of bingKey (in the search method) with your own Bing Search
API key. You can obtain a free key on the
Microsoft Cognitive
Services website. Old keys from Azure Data Market are incompatible.

Installing Eclipse as part of TADP

For recent versions of TADP, the Express installation option does not
include Eclipse. Select the Custom installation option and ensure that the
Eclipse component is checked. Alternatively, select the Complete installation
option.

More options when building from source on Windows

Recent versions of OpenCV have good support for Visual Studio 2013 (VS2013).
Use the following CMake flag to create a 32-bit VS2013 project:

-G "Visual Studio 12 2013"

Alternatively, use the following CMake flag to create a 64-bit VS2013
project:

-G "Visual Studio 12 2013 Win64"

Refer to the book for more complete instructions on CMake usage.

Mac Homebrew installation steps have changed

On Mac, if we are installing OpenCV via the latest version of Homebrew, the book's
instructions are partly outdated. Step 1 on page 18 gives the command to install
Homebrew itself, and this command has changed since I wrote the book. If you do not
already have Homebrew installed, run the following command instead:

TADP OpenCV version number

Android Application Programming with OpenCV 3

This book's 2nd edition (June 2015) is titled Android Application
Programming with OpenCV 3. The 1st edition (September 2013) is just
titled Android Application Programming with OpenCV (without the
"3"). Both editions are covered in this section.

Android OpenCV应用程序设计
(January 2015) is a Simplified Chinese translation of the 1st edition. The
English-language downloads and FAQ in this section might also help readers of
Android OpenCV应用程序设计,
but for Chinese-language support please visit
Tsinghua
University Press.

Chapter 6 is new in the book's 2nd edition. It covers OpenCV's
C++ interface and the use of Java Native Interface (JNI) to integrate
C++ code into an Android Java application.

FAQ

Q. Which OpenCV versions does the book support?

A. The book's 1st edition targets OpenCV 2.4.x. The 2nd
edition targets OpenCV 3.x with notes on backward compatibility for
OpenCV 2.4.x. The source code downloads have been updated to support both
OpenCV 2.4.x and OpenCV 3.x (separately in two downloads per chapter).

Errata and Updates (2nd Edition)

mSceneCorners should initially be empty

On page 87, mSceneCorners should be initialized as an empty matrix. This
way, the draw method (on page 92) will not draw any corners in the initial
state. The downloadable source code contains the correct initialization.

Calculating focal length

On page 108, focal length should be calculated according to the following
formula:

Errata and Updates (1st Edition)

New features including configurable image size and v7 appcompat

The source code downloads have been updated to include the following new
features:

Support for selecting an image size via the menu.

Better backward compatibility. The v7 appcompat library (part of the
Android Support Libraries) is required. Import it into your workspace as a
project (not a JAR because the JAR does not include the required
resources). The library's root folder is
<android_sdk>/extras/android/support/v7/appcompat (where
<android_sdk> is the root of the Android SDK). Edit the
application project's properties (right-click -> Properties -> Android ->
Add…) to add a reference to the v7 appcompat library project, as well
as the OpenCV library project.

Library projects may need to be on same drive as application project

On some systems, Eclipse may have difficulty linking to the library projects
(OpenCV and v7 appcompat) if the application project is located on another
drive. This may result in unresolved imports or unresolved variables, including
appcompat resource and style variables. Putting the library projects and
application project on the same drive is recommended.

Installing Eclipse as part of TADP

For recent versions of TADP, the Express installation option does not
include Eclipse. Select the Custom installation option and ensure that the
Eclipse component is checked. Alternatively, select the Complete installation
option.

NativeCameraView broken on some Android versions and some devices

OpenCV's NativeCameraView is prone to device-specific bugs and it also tends
to break when new Android OS versions come out. Symptoms of NativeCameraView
problems can include an entirely black camera view or a crash after the app is
running for about 30 seconds. One of the following errors might be logged
during the crash:

@@@ ABORTING: HEAP MEMORY CORRUPTION IN tmalloc_small

Channel is unrecoverably broken and will be disposed!

The OpenCV team continually works to patch these incompatibilities. Try
upgrading OpenCV via OpenCV Manager. If you still encounter problems, replace
all occurrences of NativeCameraView with JavaCameraView as a workaround.
JavaCameraView may be less optimized but it is more stable. The downloadable
source code now uses JavaCameraView.

If you do narrow down the problem to NativeCameraView, please help the
OpenCV community by filing a bug report on
OpenCV DevZone
(unless someone else has already filed a relevant bug report for your Android
version and device).

On pages 80-81, FeatureDetector.STAR, DescriptorExtractor.FREAK, and
DescriptorMatcher.BRUTEFORCE_HAMMING were recommended. Based on further testing
in recent versions of OpenCV, the following alternatives are actually faster
and more reliable: FeatureDetector.ORB, DescriptorExtractor.ORB, and
DescriptorMatcher.BRUTEFORCE_HAMMINGLUT. The downloadable source code uses the
latter options.

For other authors' evaluations of the algorithms and their implementations
in OpenCV, see the following sources:

mSceneCorners should initially be empty

On page 81, mSceneCorners should be initialized as an empty matrix. This
way, the draw method (on page 86) will not draw any corners in the initial
state. The downloadable source code contains the correct initialization.

Local variable akbarHunting must be defined

On pages 88-89, the definition of the local variable akbarHunting was
omitted. It must be defined in much the same way as the local variable
starryNight on page 88. The downloadable source code contains the correct
definitions.

Video size and aspect ratio in CameraProjectionAdapter

On pages 96-99, there was an unstated assumption that the size, aspect
ratio, and vertical FOV of the camera's current video mode are the same as the
size, aspect ratio, and vertical FOV that are implied by:

CameraParameters.getPictureSize; or

The combination of CameraParameters.getHorizontalViewAngle and
CameraParemeters.getVerticalViewAngle

This assumption is unsound. The downloadable source code contains a better
implementation of CameraProjectionAdapter, which takes the video size as an
additional argument to the constructor. For some formulae, this implementation
calculates an aspect ratio (and then vertical FOV) based on the size of the
current video mode. Horizontal FOV is assumed to be a constant (whose value is
given by CameraParameters.getHorizontalViewAngle) because most cameras crop
from the top and bottom ("letterboxing") to obtain video modes with a
different aspect ratio than the sensor's physical aspect ratio.

For the calculation of focal length, the uncropped horizontal FOV, vertical
FOV, and aspect ratio are still used.

Calculating focal length

On page 99, focal length should be calculated according to the following
formula:

Python Game Programming by Example

Downloads

OpenCV Computer Vision with Python

This book's 2nd edition (September 2015) is titled Learning OpenCV 3
Computer Vision with Python. See
Joe Minichino's support site
for the 2nd edition. The 1st edition (September 2013) is just titled
OpenCV Computer Vision with Python and it is covered in this
section.

OpenNI Binaries for Use with SensorKinect on Windows

Since openni.org is defunct, binaries can no longer be downloaded from that site.
Instead, get them from this book's Downloads
section, above.

Captured Frame may be None

The book's sample code assumes that frames in a camera capture session are reliably
non-None (until the session terminates). This assumption is wrong. For some
cameras, the first few frames of a session may be None, yet subsequent frames may be
non-None. The source code downloads, above, are corrected so that the program's main
loop continues even if a given frame is None.

Reported Frame Rate may be Negative

The book's sample code assumes that OpenCV always reports a non-negative value for the
capture frame rate. On some platforms, including Ubuntu, this assumption is wrong. When
the assumption is violated, the sample code may produce the following error message, which
is misleading:

When OpenCV reports a negative frame rate, we should measure the actual frame rate
instead, just as we do when OpenCV reports a frame rate of 0.0. The fix is to modify the
following conditional statement in managers.py:

if fps == 0.0:

Here is the corrected version:

if fps <= 0.0:

This change is incorporated into the source code downloads, above.

Kinect Model 1473 Unsupported on Mac OS X Mountain Lion

The sample code for Chapter 5 is tested successfully with Kinect Model 1414. On some
platforms, other Kinect models may be unsupported by the SensorKinect driver.
Specifically, the driver is known to fail on Mac OS X Mountain Lion for Kinect Model
1473. (It crashes after about 20 seconds of input.)

The model number should be printed on the bottom of the Kinect device.

Mac Homebrew Installation Steps Have Changed

On Mac, if we are installing OpenCV via the latest version of Homebrew, the book's
instructions are partly outdated. Step 1 on page 16 gives the command to install
Homebrew itself, and this command has changed since I wrote the book. If you do not
already have Homebrew installed, run the following command instead: