Table of Contents
OpenCV By Example
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Getting Started with OpenCV
Understanding the human visual system
How do humans understand image content?
Why is it difficult for machines to understand image content?
What can you do with OpenCV?
In-built data structures and input/output
Image processing operations
Building GUI
Video analysis
3D reconstruction
Feature extraction
Object detection
Machine learning
Computational photography
Shape analysis
Optical flow algorithms
Face and object recognition
Surface matching
Text detection and recognition
Installing OpenCV
Windows
Mac OS X
Linux
Summary
2. An Introduction to the Basics of OpenCV
Basic CMake configuration files
Creating a library
Managing dependencies
Making the script more complex
Images and matrices
Reading/writing images
Reading videos and cameras
Other basic object types
The vec object type
The Scalar object type
The Point object type
The Size object type
The Rect object type
RotatedRect object type
Basic matrix operations
Basic data persistence and storage
Writing to a file storage
Summary
3. Learning the Graphical User Interface and Basic Filtering
Introducing the OpenCV user interface
A basic graphical user interface with OpenCV
The graphical user interface with QT
Adding slider and mouse events to our interfaces
Adding buttons to a user interface
OpenGL support
Summary
4. Delving into Histograms and Filters
Generating a CMake script file
Creating the Graphical User Interface
Drawing a histogram
Image color equalization
Lomography effect
The cartoonize effect
Summary
5. Automated Optical Inspection, Object Segmentation, and Detection
Isolating objects in a scene
Creating an application for AOI
Preprocessing the input image
Noise removal
Removing the background using the light pattern for segmentation
The thresholding operation
Segmenting our input image
The connected component algorithm
The findContours algorithm
Summary
6. Learning Object Classification
Introducing machine learning concepts
Computer Vision and the machine learning workflow
Automatic object inspection classification example
Feature extraction
Training an SVM model
Input image prediction
Summary
7. Detecting Face Parts and Overlaying Masks
Understanding Haar cascades
What are integral images?
Overlaying a facemask in a live video
What happened in the code?
Get your sunglasses on
Looking inside the code
Tracking your nose, mouth, and ears
Summary
8. Video Surveillance, Background Modeling, and Morphological Operations
Understanding background subtraction
Naive background subtraction
Does it work well?
Frame differencing
How well does it work?
The Mixture of Gaussians approach
What happened in the code?
Morphological image processing
What's the underlying principle?
Slimming the shapes
Thickening the shapes
Other morphological operators
Morphological opening
Morphological closing
Drawing the boundary
White Top-Hat transform
Black Top-Hat transform
Summary
9. Learning Object Tracking
Tracking objects of a specific color
Building an interactive object tracker
Detecting points using the Harris corner detector
Shi-Tomasi Corner Detector
Feature-based tracking
The Lucas-Kanade method
The Farneback algorithm
Summary
10. Developing Segmentation Algorithms for Text Recognition
Introducing optical character recognition
The preprocessing step
Thresholding the image
Text segmentation
Creating connected areas
Identifying paragraph blocks
Text extraction and skew adjustment
Installing Tesseract OCR on your operating system
Installing Tesseract on Windows
Setting up Tesseract in Visual Studio
Setting the import and library paths
Configuring the linker
Adding the libraries to the windows path
Installing Tesseract on Mac
Using Tesseract OCR library
Creating a OCR function
Sending the output to a file
Summary
11. Text Recognition with Tesseract
How the text API works
The scene detection problem
Extremal regions
Extremal region filtering
Using the text API
Text detection
Text extraction
Text recognition
Summary
Index
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: January 2016
Production reference: 1150116
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-094-8
www.packtpub.com
Authors
Prateek Joshi
David MillĂĄn EscrivĂĄ
VinĂcius Godoy
Reviewers
Emmanuel d'Angelo
Dr. Bryan Wai-ching CHUNG
Nikolaus Gradwohl
Luis DĂaz MĂĄs
Commissioning Editor
Ashwin Nair
Acquisition Editor
Tushar Gupta
Content Development Editor
Amey Varangaonkar
Technical Editor
Naveenkumar Jain
Copy Editor
Rashmi Sawant
Project Coordinator
Suzanne Coutinho
Proofreader
Safis Editing
Indexer
Hemangini Bari
Graphics
Kirk D'Penha
Production Coordinator
Shantanu N. Zagade
Cover Work
Shantanu N. Zagade
Prateek Joshi is a Computer Vision researcher and published author. He has over eight years of experience in this field with a primary focus on content-based analysis and deep learning. His work in this field has resulted in multiple patents, tech demos, and research papers at major IEEE conferences. He is the author of OpenCV with Python By Example, Packt Publishing.
He has won many hackathons using a wide variety of technologies related to image recognition. His blog has been visited by users in more than 200 countries, and...