OpenCV 4 Computer Vision Application Programming Cookbook - Fourth Edition

Book description

Discover interesting recipes to help you understand the concepts of object detection, image processing, and facial detection

Key Features

  • Explore the latest features and APIs in OpenCV 4 and build computer vision algorithms
  • Develop effective, robust, and fail-safe vision for your applications
  • Build computer vision algorithms with machine learning capabilities

Book Description

OpenCV is an image and video processing library used for all types of image and video analysis. Throughout the book, you'll work through recipes that implement a variety of tasks. With 70 self-contained tutorials, this book examines common pain points and best practices for computer vision (CV) developers. Each recipe addresses a specific problem and offers a proven, best-practice solution with insights into how it works, so that you can copy the code and configuration files and modify them to suit your needs.

This book begins by setting up OpenCV, and explains how to manipulate pixels. You'll understand how you can process images with classes and count pixels with histograms. You'll also learn detecting, describing, and matching interest points. As you advance through the chapters, you'll get to grips with estimating projective relations in images, reconstructing 3D scenes, processing video sequences, and tracking visual motion. In the final chapters, you'll cover deep learning concepts such as face and object detection.

By the end of the book, you'll be able to confidently implement a range of computer vision algorithms to meet the technical requirements of your complex CV projects.

What you will learn

  • Install and create a program using the OpenCV library
  • Segment images into homogenous regions and extract meaningful objects
  • Apply image filters to enhance image content
  • Exploit image geometry to relay different views of a pictured scene
  • Calibrate the camera from different image observations
  • Detect people and objects in images using machine learning techniques
  • Reconstruct a 3D scene from images
  • Explore face detection using deep learning

Who this book is for

If you’re a CV developer or professional who already uses or would like to use OpenCV for building computer vision software, this book is for you. You’ll also find this book useful if you’re a C++ programmer looking to extend your computer vision skillset by learning OpenCV.

Downloading the example code for this ebook: You can download the example code files for this ebook on GitHub at the following link: https://github.com/PacktPublishing/OpenCV-4-Computer-Vision-Application-Programming-Cookbook-Fourth-Edition. If you require support please email: customercare@packt.com

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. OpenCV 4 Computer Vision Application Programming Cookbook Fourth Edition
  3. About Packt
    1. Why subscribe?
    2. Packt.com
  4. Contributors
    1. About the authors
    2. About the reviewers
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Sections
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    5. Get in touch
      1. Reviews
  6. Playing with Images
    1. Installing the OpenCV library
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
        1. Using Qt for OpenCV developments
        2. The OpenCV developer site
      5. See also
    2. Loading, displaying, and saving images
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
        1. Clicking on images
        2. Drawing on images
        3. Running the example with Qt
      5. See also
    3. Exploring the cv::Mat data structure
      1. How to do it...
      2. How it works...
      3. There's more...
        1. The input and output arrays
      4. See also
    4. Defining regions of interest
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
        1. Using image masks
      5. See also
  7. Manipulating the Pixels
    1. Accessing pixel values
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
        1. The cv::Mat_ template class
      5. See also
    2. Scanning an image with pointers
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
        1. Other color reduction formulas
        2. Having input and output arguments
        3. Efficient scanning of continuous images
        4. Low-level pointer arithmetics
      5. See also
    3. Scanning an image with iterators
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    4. Writing efficient image-scanning loops
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    5. Scanning an image with neighbor access
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    6. Performing simple image arithmetic
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
        1. Overloaded image operators
        2. Splitting the image channels
    7. Remapping an image
      1. How to do it...
      2. How it works...
      3. See also
  8. Processing Color Images with Classes
    1. Comparing colors using the strategy design pattern
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Computing the distance between two color vectors
        2. Using OpenCV functions
        3. The functor or function object
        4. The OpenCV base class for algorithms
      4. See also
    2. Segmenting an image with the GrabCut algorithm
      1. How to do it...
      2. How it works...
      3. See also
    3. Converting color representations
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Representing colors with hue, saturation, and brightness
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Using colors for detection – skin tone detection
  9. Counting the Pixels with Histograms
    1. Computing the image histogram
      1. Getting started
      2. How to do it...
      3. How it works...
      4. There's more...
        1. Computing histograms of color images
      5. See also
    2. Applying lookup tables to modify the image's appearance
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Stretching a histogram to improve the image contrast
        2. Applying a lookup table on color images
    3. Equalizing the image histogram
      1. How to do it...
      2. How it works...
    4. Backprojecting a histogram to detect specific image content
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Backprojecting color histograms
    5. Using the mean shift algorithm to find an object
      1. How to do it...
      2. How it works...
      3. See also
    6. Retrieving similar images using histogram comparison
      1. How to do it...
      2. How it works...
      3. See also
    7. Counting pixels with integral images
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Adaptive thresholding
        2. Visual tracking using histograms
      4. See also
  10. Transforming Images with Morphological Operations
    1. Eroding and dilating images using morphological filters
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    2. Opening and closing images using morphological filters
      1. How to do it...
      2. How it works...
      3. See also
    3. Detecting edges and corners using morphological filters
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Segmenting images using watersheds
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    5. Extracting distinctive regions using MSER
      1. How to do it...
      2. How it works...
      3. See also
    6. Extracting foreground objects with the GrabCut algorithm
      1. How to do it...
      2. How it works...
      3. See also
  11. Filtering the Images
    1. Filtering images using low-pass filters
      1. How to do it...
      2. How it works...
      3. See also
    2. Downsampling an image
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Interpolating pixel values
      4. See also
    3. Filtering images using a median filter
      1. How to do it...
      2. How it works...
    4. Applying directional filters to detect edges
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Gradient operators
        2. Gaussian derivatives
      4. See also
    5. Computing the Laplacian of an image
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Enhancing the contrast of an image using the Laplacian
        2. Difference of Gaussians
      4. See also
  12. Extracting Lines, Contours, and Components
    1. Detecting image contours with the Canny operator
      1. How to do it...
      2. How it works...
      3. See also
    2. Detecting lines in images with the Hough transform
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
        1. Detecting circles
      5. See also
    3. Fitting a line to a set of points
      1. How to do it...
      2. How it works...
      3. There's more...
    4. Extracting the components' contours
      1. How to do it...
      2. How it works...
      3. There's more...
    5. Computing components' shape descriptors
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Quadrilateral detection
  13. Detecting Interest Points
    1. Detecting corners in an image
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Good features to track
        2. The feature detector's common interface
      4. See also
    2. Detecting features quickly
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Adapted feature detection
      4. See also
    3. Detecting scale-invariant features
      1. How to do it...
      2. How it works...
      3. There's more...
        1. The SIFT feature-detection algorithm
      4. See also
    4. Detecting FAST features at multiple scales
      1. How to do it...
      2. How it works...
      3. There's more...
        1. The ORB feature-detection algorithm
      4. See also
  14. Describing and Matching Interest Points
    1. Matching local templates
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Template matching
      4. See also
    2. Describing local intensity patterns
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Cross-checking matches
        2. The ratio test
        3. Distance thresholding
      4. See also
    3. Describing keypoints with binary features
      1. How to do it...
      2. How it works...
      3. There's more...
        1. FREAK
      4. See also
  15. Estimating Projective Relations in Images
    1. Computing the fundamental matrix of an image pair
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    2. Matching images using a random sample consensus
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Refining the fundamental matrix
        2. Refining the matches
    3. Computing a homography between two images
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Detecting planar targets in an image
      1. How to do it...
      2. See also
  16. Reconstructing 3D Scenes
    1. Digital image formation
    2. Calibrating a camera
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
        1. Calibration with known intrinsic parameters
        2. Using a grid of circles for calibration
      5. See also
    3. Recovering the camera pose
      1. How to do it...
      2. How it works...
      3. There's more...
        1. cv::Viz – a 3D visualizer module
      4. See also
    4. Reconstructing a 3D scene from calibrated cameras
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Decomposing a homography
        2. Bundle adjustment
      4. See also
    5. Computing depth from a stereo image
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
  17. Processing Video Sequences
    1. Reading video sequences
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    2. Processing video frames
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Processing a sequence of images
        2. Using a frame processor class
      4. See also
    3. Writing video sequences
      1. How to do it...
      2. How it works...
      3. There's more...
        1. The codec four-character code
      4. See also
    4. Extracting the foreground objects in a video
      1. How to do it...
      2. How it works...
      3. There's more...
        1. The mixture of Gaussian method
      4. See also
  18. Tracking Visual Motion
    1. Tracing feature points in a video
      1. How to do it...
      2. How it works...
      3. See also
    2. Estimating the optical flow
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    3. Tracking an object in a video
      1. How to do it...
      2. How it works...
      3. See also
  19. Learning from Examples
    1. Recognizing faces using the nearest neighbors of local binary patterns
      1. How to do it...
      2. How it works...
      3. See also
    2. Finding objects and faces with a cascade of Haar features
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
        1. Face detection with a Haar cascade
      5. See also
    3. Detecting objects and people using SVMs and histograms of oriented gradients
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
        1. HOG visualization
        2. People detection
        3. Deep learning and convolutional neural networks (CNNs)
      5. See also
  20. OpenCV Advanced Features
    1. Face detection using deep learning
      1. How to do it...
      2. How it works...
      3. See also
    2. Object detection with YOLOv3
      1. How to do it...
      2. How it works...
      3. See also
    3. Enabling Halide to improve efficiency
      1. How to do it...
      2. How it works...
      3. See also
    4. OpenCV.js introduction
      1. How to do it...
      2. How it works...
  21. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: OpenCV 4 Computer Vision Application Programming Cookbook - Fourth Edition
  • Author(s): David Millan Escriva, Robert Laganiere
  • Release date: May 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781789340723