Mastering OpenCV 4 - Third Edition

Book description

Work on practical computer vision projects covering advanced object detector techniques and modern deep learning and machine learning algorithms

Key Features

  • Learn about the new features that help unlock the full potential of OpenCV 4
  • Build face detection applications with a cascade classifier using face landmarks
  • Create an optical character recognition (OCR) model using deep learning and convolutional neural networks

Book Description

Mastering OpenCV, now in its third edition, targets computer vision engineers taking their first steps toward mastering OpenCV. Keeping the mathematical formulations to a solid but bare minimum, the book delivers complete projects from ideation to running code, targeting current hot topics in computer vision such as face recognition, landmark detection and pose estimation, and number recognition with deep convolutional networks.

You'll learn from experienced OpenCV experts how to implement computer vision products and projects both in academia and industry in a comfortable package. You'll get acquainted with API functionality and gain insights into design choices in a complete computer vision project. You'll also go beyond the basics of computer vision to implement solutions for complex image processing projects.

By the end of the book, you will have created various working prototypes with the help of projects in the book and be well versed with the new features of OpenCV4.

What you will learn

  • Build real-world computer vision problems with working OpenCV code samples
  • Uncover best practices in engineering and maintaining OpenCV projects
  • Explore algorithmic design approaches for complex computer vision tasks
  • Work with OpenCV's most updated API (v4.0.0) through projects
  • Understand 3D scene reconstruction and Structure from Motion (SfM)
  • Study camera calibration and overlay AR using the ArUco Module

Who this book is for

This book is for those who have a basic knowledge of OpenCV and are competent C++ programmers. You need to have an understanding of some of the more theoretical/mathematical concepts, as we move quite quickly throughout the book.

Publisher resources

View/Submit Errata

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering OpenCV 4 Third Edition
  3. Dedication
  4. About Packt
    1. Why subscribe?
    2. Packt.com
  5. Contributors
    1. About the authors
    2. About the reviewers
    3. Packt is searching for authors like you
  6. 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. Get in touch
      1. Reviews
  7. Cartoonifier and Skin Color Analysis on the RaspberryPi
    1. Accessing the webcam
    2. Main camera processing loop for a desktop app
      1. Generating a black and white sketch
      2. Generating a color painting and a cartoon
      3. Generating an evil mode using edge filters
      4. Generating an alien mode using skin detection
        1. Skin detection algorithm
        2. Showing the user where to put their face
    3. Implementation of the skin color changer
      1. Reducing the random pepper noise from the sketch image
    4. Porting from desktop to an embedded device
      1. Equipment setup to develop code for an embedded device
        1. Configuring a new Raspberry Pi
      2. Installing OpenCV on an embedded device
        1. Using the Raspberry Pi Camera Module
          1. Installing the Raspberry Pi Camera Module driver
        2. Making Cartoonifier run in fullscreen
        3. Hiding the mouse cursor
        4. Running Cartoonifier automatically after bootup
        5. Speed comparison of Cartoonifier on desktop versus embedded
          1. Changing the camera and camera resolution
        6. Power draw of Cartoonifier running on desktop versus embedded system
          1. Streaming video from Raspberry Pi to a powerful computer
        7. Customizing your embedded system!
    5. Summary
  8. Explore Structure from Motion with the SfM Module
    1. Technical requirements
    2. Core concepts of SfM
      1. Calibrated cameras and epipolar geometry
      2. Stereo reconstruction and SfM
    3. Implementing SfM in OpenCV
      1. Image feature matching
      2. Finding feature tracks
      3. 3D reconstruction and visualization
      4. MVS for dense reconstruction
    4. Summary
  9. Face Landmark and Pose with the Face Module
    1. Technical requirements
    2. Theory and context
      1. Active appearance models and constrained local models
      2. Regression methods
    3. Facial landmark detection in OpenCV
      1. Measuring error
    4. Estimating face direction from landmarks
      1. Estimated pose calculation
      2. Projecting the pose on the image
    5. Summary
  10. Number Plate Recognition with Deep Convolutional Networks
    1. Introduction to ANPR
    2. ANPR algorithm
    3. Plate detection
      1. Segmentation
      2. Classification
    4. Plate recognition
      1. OCR segmentation
      2. Character classification using a convolutional neural network
        1. Creating and training a convolutional neural network with TensorFlow
          1. Preparing the data
          2. Creating a TensorFlow model
          3. Preparing a model for OpenCV
          4. Import and use model in OpenCV C++ code
    5. Summary
  11. Face Detection and Recognition with the DNN Module
    1. Introduction to face detection and face recognition
      1. Face detection
        1. Implementing face detection using OpenCV cascade classifiers
          1. Loading a Haar or LBP detector for object or face detection
          2. Accessing the webcam
          3. Detecting an object using the Haar or LBP classifier
          4. Detecting the face
        2. Implementing face detection using the OpenCV deep learning module
      2. Face preprocessing
        1. Eye detection
        2. Eye search regions
          1. Geometrical transformation
          2. Separate histogram equalization for left and right sides
          3. Smoothing
          4. Elliptical mask
      3. Collecting faces and learning from them
        1. Collecting preprocessed faces for training
        2. Training the face recognition system from collected faces
        3. Viewing the learned knowledge
        4. Average face
        5. Eigenvalues, Eigenfaces, and Fisherfaces
      4. Face recognition
        1. Face identification – recognizing people from their faces
        2. Face verification—validating that it is the claimed person
      5. Finishing touches—saving and loading files
      6. Finishing touches—making a nice and interactive GUI
        1. Drawing the GUI elements
          1. Startup mode
          2. Detection mode
          3. Collection mode
          4. Training mode
          5. Recognition mode
        2. Checking and handling mouse clicks
    2. Summary
    3. References
  12. Introduction to Web Computer Vision with OpenCV.js
    1. What is OpenCV.js?
    2. Compile OpenCV.js
    3. Basic introduction to OpenCV.js development
    4. Accessing webcam streams
    5. Image processing and basic user interface
      1. Threshold filter
      2. Gaussian filter
      3. Canny filter
    6. Optical flow in your browser
    7. Face detection using a Haar cascade classifier in your browser
    8. Summary
  13. Android Camera Calibration and AR Using the ArUco Module
    1. Technical requirements
    2. Augmented reality and pose estimation
      1. Camera calibration
      2. Augmented reality markers for planar reconstruction
    3. Camera access in Android OS
      1. Finding and opening the camera
    4. Camera calibration with ArUco
    5. Augmented reality with jMonkeyEngine
    6. Summary
  14. iOS Panoramas with the Stitching Module
    1. Technical requirements
    2. Panoramic image stitching methods
      1. Feature extraction and robust matching for panoramas
        1. Affine constraint
        2. Random sample consensus (RANSAC)
        3. Homography constraint
        4. Bundle Adjustment
      2. Warping images for panorama creation
    3. Project overview
    4. Setting up an iOS OpenCV project with CocoaPods 
    5. iOS UI for panorama capture
    6. OpenCV stitching in an Objective-C++ wrapper
    7. Summary
    8. Further reading
  15. Finding the Best OpenCV Algorithm for the Job
    1. Technical requirements
    2. Is it covered in OpenCV?
    3. Algorithm options in OpenCV
    4. Which algorithm is best?
    5. Example comparative performance test of algorithms
    6. Summary
  16. Avoiding Common Pitfalls in OpenCV
    1. History of OpenCV from v1 to v4
      1. OpenCV and the data revolution in computer vision
    2. Historic algorithms in OpenCV
      1. How to check when an algorithm was added to OpenCV
    3. Common pitfalls and suggested solutions
    4. Summary
    5. Further reading
  17. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Mastering OpenCV 4 - Third Edition
  • Author(s): Roy Shilkrot, David Millan Escriva
  • Release date: December 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781789533576