Book Image

OpenCV 3 Blueprints

By : Matthew John Macdonald, Jason Clemons, Gary Bradski, Alasdair McAndrew, Steven Puttemans, Joseph Howse, Utkarsh Sinha, Quan Hua
Book Image

OpenCV 3 Blueprints

By: Matthew John Macdonald, Jason Clemons, Gary Bradski, Alasdair McAndrew, Steven Puttemans, Joseph Howse, Utkarsh Sinha, Quan Hua

Overview of this book

Table of Contents (14 chapters)
OpenCV 3 Blueprints
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Open source computer vision projects, such as OpenCV 3, enable all kinds of users to harness the forces of machine vision, machine learning, and artificial intelligence. By mastering these powerful libraries of code and knowledge, professionals and hobbyists can create smarter, better applications wherever they are needed.

This is exactly where this book is focused, guiding you through a set of hands-on projects and templates, which will teach you to combine fantastic techniques in order to solve your specific problem.

As we study computer vision, let's take inspiration from these words:

 

"I saw that wisdom is better than folly, just as light is better than darkness."

 
 --Ecclesiastes, 2:13

Let's build applications that see clearly, and create knowledge.

What this book covers

Chapter 1, Getting the Most out of Your Camera System, discusses how to select and configure camera systems to see invisible light, fast motion, and distant objects.

Chapter 2, Photographing Nature and Wildlife with an Automated Camera, shows how to build a "camera trap", as used by nature photographers, and process photos to create beautiful effects.

Chapter 3, Recognizing Facial Expressions with Machine Learning, explores ways to build a facial expression recognition system with various feature extraction techniques and machine learning methods.

Chapter 4, Panoramic Image Stitching Application Using Android Studio and NDK, focuses on the project of building a panoramic camera app for Android with the help of OpenCV 3's stitching module. We will use C++ with Android NDK.

Chapter 5, Generic Object Detection for Industrial Applications, investigates ways to optimize your object detection model, make it rotation invariant, and apply scene-specific constraints to make it faster and more robust.

Chapter 6, Efficient Person Identification Using Biometric Properties, is about building a person identification and registration system based on biometric properties of that person, such as their fingerprint, iris, and face.

Chapter 7, Gyroscopic Video Stabilization, demonstrates techniques for fusing data from videos and gyroscopes, how to stabilize videos shot on your mobile phone, and how to create hyperlapse videos.

What you need for this book

As a basic setup, the complete book is based on the OpenCV 3 software. If a chapter does not have a specific OS requirement, then it will run on Windows, Linux, and Mac. As authors, we encourage you to take the latest master branch from the official GitHub repository (https://github.com/Itseez/opencv/) for setting up your OpenCV installation, rather then using the downloadable packages at the official OpenCV website (http://opencv.org/downloads.html), since the latest master branch contains a huge number of fixes compared to the latest stable release.

For hardware, the authors expect that you have a basic computer system setup, either a desktop or a laptop, with at least 4 GB of RAM memory available. Other hardware requirements are mentioned below.

The following chapters have specific requirements that come on top of the OpenCV 3 installation:

Chapter 1, Getting the Most out of Your Camera System:

  • Software: OpenNI2 and FlyCapture 2.

  • Hardware: PS3 Eye camera or any other USB webcam, an Asus Xtion PRO live or any other OpenNI-compatible depth camera, and a Point Grey Research (PGR) camera with one or more lenses.

  • Remarks: The PGR camera setup (with FlyCapture 2) will not run on Mac. Even if you do not have all the required hardware, you can still benefit from some sections of this chapter.

Chapter 2, Photographing Nature and Wildlife with an Automated Camera:

  • Software: Linux or Mac operating system.

  • Hardware: A portable laptop or a single-board computer (SBC) with battery, combined with a photo camera.

Chapter 4, Panoramic Image Stitching Application Using Android Studio and NDK:

  • Software: Android 4.4 or later, Android NDK.

  • Hardware: Any mobile device that supports Android 4.4 or later.

Chapter 7, Gyroscopic Video Stabilization:

  • Software: NumPy, SciPy, Python, and Android 5.0 or later, and the Android NDK.

  • Hardware: A mobile phone that supports Android 5.0 or later for capturing video and gyroscope signals.

Basic installation guides

As authors, we acknowledge that installing OpenCV 3 on your system can sometimes be quite cumbersome. Therefore, we have added a series of basic installation guides for installing OpenCV 3, based on the latest OpenCV 3 master branch on your system, and getting the necessary modules for the different chapters to work. For more information, take a look at https://github.com/OpenCVBlueprints/OpenCVBlueprints/tree/master/installation_tutorials.

Keep in mind that the book also uses modules from the OpenCV "contrib" (contributed) repository. The installation manual will have directions on how to install these. However, we encourage you to only install those modules that we need, because we know that they are stable. For other modules, this might not be the case.

Who this book is for

This book is ideal for you if you aspire to build computer vision systems that are smarter, faster, more complex, and more practical than the competition. This is an advanced book, intended for those who already have some experience in setting up an OpenCV development environment and building applications with OpenCV. You should be comfortable with computer vision concepts, object-oriented programming, graphics programming, IDEs, and the command line.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "You can find the OpenCV software by going to http://opencv.org and clicking on the download link."

A block of code is set as follows:

Mat input = imread("/data/image.png", LOAD_IMAGE_GRAYSCALE);
GaussianBlur(input, input, Size(7,7), 0, 0);
imshow("image", input);
waitKey(0);

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

Mat input = imread("/data/image.png", LOAD_IMAGE_GRAYSCALE);
GaussianBlur(input, input, Size(7,7), 0, 0);
imshow("image", input);
waitKey(0);

Any command-line input or output is written as follows:

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button moves you to the next screen."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

The code is also maintained on a GitHub repository by the authors of this book. This code repository can be found at https://github.com/OpenCVBlueprints/OpenCVBlueprints.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/B04028_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Since this book also has a GitHub repository assigned to it, you can also report content errata by creating an issue at the following page: https://github.com/OpenCVBlueprints/OpenCVBlueprints/issues.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem. Or as mentioned before, you could open up an issue on the GitHub repository and one of the authors will help you as soon as possible.