O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning OpenCV 3 Application Development

Book Description

Build, create, and deploy your own computer vision applications with the power of OpenCV

About This Book

  • This book provides hands-on examples that cover the major features that are part of any important Computer Vision application
  • It explores important algorithms that allow you to recognize faces, identify objects, extract features from images, help your system make meaningful predictions from visual data, and much more
  • All the code examples in the book are based on OpenCV 3.1 – the latest version

Who This Book Is For

This is the perfect book for anyone who wants to dive into the exciting world of image processing and computer vision. This book is aimed at programmers with a working knowledge of C++. Prior knowledge of OpenCV or Computer Vision/Machine Learning is not required.

What You Will Learn

  • Explore the steps involved in building a typical computer vision/machine learning application
  • Understand the relevance of OpenCV at every stage of building an application
  • Harness the vast amount of information that lies hidden in images into the apps you build
  • Incorporate visual information in your apps to create more appealing software
  • Get acquainted with how large-scale and popular image editing apps such as Instagram work behind the scenes by getting a glimpse of how the image filters in apps can be recreated using simple operations in OpenCV
  • Appreciate how difficult it is for a computer program to perform tasks that are trivial for human beings
  • Get to know how to develop applications that perform face detection, gender detection from facial images, and handwritten character (digit) recognition

In Detail

Computer vision and machine learning concepts are frequently used in practical computer vision based projects. If you’re a novice, this book provides the steps to build and deploy an end-to-end application in the domain of computer vision using OpenCV/C++.

At the outset, we explain how to install OpenCV and demonstrate how to run some simple programs. You will start with images (the building blocks of image processing applications), and see how they are stored and processed by OpenCV. You’ll get comfortable with OpenCV-specific jargon (Mat Point, Scalar, and more), and get to know how to traverse images and perform basic pixel-wise operations.

Building upon this, we introduce slightly more advanced image processing concepts such as filtering, thresholding, and edge detection. In the latter parts, the book touches upon more complex and ubiquitous concepts such as face detection (using Haar cascade classifiers), interest point detection algorithms, and feature descriptors. You will now begin to appreciate the true power of the library in how it reduces mathematically non-trivial algorithms to a single line of code!

The concluding sections touch upon OpenCV’s Machine Learning module. You will witness not only how OpenCV helps you pre-process and extract features from images that are relevant to the problems you are trying to solve, but also how to use Machine Learning algorithms that work on these features to make intelligent predictions from visual data!

Style and approach

This book takes a very hands-on approach to developing an end-to-end application with OpenCV. To avoid being too theoretical, the description of concepts are accompanied simultaneously by the development of applications. Throughout the course of the book, the projects and practical, real-life examples are explained and developed step by step in sync with the theory.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Learning OpenCV 3 Application Development
    1. Learning OpenCV 3 Application Development
    2. Credits
    3. About the Author
    4. About the Reviewer
    5. www.PacktPub.com
      1. Why subscribe?
    6. Preface
      1. What this book covers 
      2. Who this book is for 
      3. What you need for this book 
      4. Conventions 
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    7. 1. Laying the Foundation
      1. Digital image basics
        1. Pixel intensities
        2. Color depth and color spaces
        3. Color channels
      2. Introduction to the Mat class
      3. Exploring the Mat class: loading images
      4. Exploring the Mat class - declaring Mat objects
        1. Spatial dimensions of an image
        2. Color space or color depth
        3. Color channels
        4. Image size
        5. Default initialization value
      5. Digging inside Mat objects
      6. Traversing Mat objects
        1. Continuity of the Mat data matrix
        2. Image traversals
      7. Image enhancement
      8. Lookup tables
      9. Linear transformations
        1. Identity transformation
        2. Negative transformation
      10. Logarithmic transformations
        1. Log transformation
        2. Exponential or inverse-log transformation
      11. Summary
    8. 2. Image Filtering
      1. Neighborhood of a pixel
      2. Image averaging
      3. Image filters
      4. Image averaging in OpenCV
      5. Blurring an image in OpenCV
      6. Gaussian smoothing
      7. Gaussian function and Gaussian filtering
      8. Gaussian filtering in OpenCV
      9. Using your own filters in OpenCV
      10. Image noise
      11. Vignetting
      12. Implementing Vignetting in OpenCV
      13. Summary
    9. 3. Image Thresholding
      1. Binary images
      2. Image thresholding basics
      3. Image thresholding in OpenCV
      4. Types of simple image thresholding
        1. Binary threshold
        2. Inverted binary threshold
        3. Truncate
        4. Threshold-to-zero
        5. Inverted threshold-to-zero
      5. Adaptive thresholding
      6. Morphological operations
      7. Erosion and dilation
      8. Erosion and dilation in OpenCV
      9. Summary
    10. 4. Image Histograms
      1. The basics of histograms
      2. Histograms in OpenCV
      3. Plotting histograms in OpenCV
      4. Color histograms in OpenCV
      5. Multidimensional histograms in OpenCV
      6. Summary
    11. 5. Image Derivatives and Edge Detection
      1. Image derivatives
      2. Image derivatives in two dimensions
      3. Visualizing image derivatives with OpenCV
      4. The Sobel derivative filter
      5. From derivatives to edges
      6. The Sobel detector - a basic framework for edge detection
      7. The Canny edge detector
      8. Image noise and edge detection
      9. Laplacian - yet another edge detection technique
      10. Blur detection using OpenCV
      11. Summary
    12. 6. Face Detection Using OpenCV
      1. Image classification systems
      2. Face detection
      3. Haar features
      4. Integral image
        1. Integral image in OpenCV
      5. AdaBoost learning
      6. Cascaded classifiers
      7. Face detection in OpenCV
        1. Controlling the quality of detected faces
      8. Gender classification
      9. Working with real datasets
      10. Summary
    13. 7. Affine Transformations and Face Alignment
      1. Exploring the dataset
        1. Running face detection on the dataset
      2. Face alignment - the first step in facial analysis
      3. Rotating faces
      4. Image cropping -- basics
      5. Image cropping for face alignment
      6. Face alignment - the complete pipeline
      7. Summary
    14. 8. Feature Descriptors in OpenCV
      1. Introduction to the local binary pattern
      2. A basic implementation of LBP
      3. Variants of LBP
      4. What does LBP capture?
      5. Applying LBP to aligned facial images
      6. A complete implementation of LBP
      7. Putting it all together - the main() function
      8. Summary
    15. 9. Machine Learning with OpenCV
      1. What is machine learning
      2. Supervised and unsupervised learning
      3. Revisiting the image classification framework
      4. k-means clustering - the basics
        1. k-means clustering - the algorithm
        2. k-means clustering in OpenCV
      5. k-nearest neighbors classifier - introduction
        1. k-nearest neighbors classifier - algorithm
        2. What k to use
        3. k-nearest neighbors classifier in OpenCV
        4. Some problems with kNN
        5. Some enhancements to kNN
      6. Support vector machines (SVMs) - introduction
        1. Intuition into the workings of SVMs
      7. Non-linear SVMs
        1. SVM in OpenCV
      8. Using an SVM as a gender classifier
      9. Overfitting
      10. Cross-validation
      11. Common evaluation metrics
      12. The P-R curve
      13. Some qualitative results
      14. Summary
    16. A. Command-line Arguments in C++
      1. Introduction to command-line arguments
        1. Parsing command-line arguments
      2. Summary