OpenCV 3.x with Python By Example - Second Edition

Book description

Learn the techniques for object recognition, 3D reconstruction, stereo imaging, and other computer vision applications using examples on different functions of OpenCV.

About This Book

  • Learn how to apply complex visual effects to images with OpenCV 3.x and Python
  • Extract features from an image and use them to develop advanced applications
  • Build algorithms to help you understand image content and perform visual searches
  • Get to grips with advanced techniques in OpenCV such as machine learning, artificial neural network, 3D reconstruction, and augmented reality

Who This Book Is For

This book is intended for Python developers who are new to OpenCV and want to develop computer vision applications with OpenCV and Python. This book is also useful for generic software developers who want to deploy computer vision applications on the cloud. It would be helpful to have some familiarity with basic mathematical concepts such as vectors, matrices, and so on.

What You Will Learn

  • Detect shapes and edges from images and videos
  • How to apply filters on images and videos
  • Use different techniques to manipulate and improve images
  • Extract and manipulate particular parts of images and videos
  • Track objects or colors from videos
  • Recognize specific object or faces from images and videos
  • How to create Augmented Reality applications
  • Apply artificial neural networks and machine learning to improve object recognition

In Detail

Computer vision is found everywhere in modern technology. OpenCV for Python enables us to run computer vision algorithms in real time. With the advent of powerful machines, we have more processing power to work with. Using this technology, we can seamlessly integrate our computer vision applications into the cloud. Focusing on OpenCV 3.x and Python 3.6, this book will walk you through all the building blocks needed to build amazing computer vision applications with ease.

We start off by manipulating images using simple filtering and geometric transformations. We then discuss affine and projective transformations and see how we can use them to apply cool advanced manipulations to your photos like resizing them while keeping the content intact or smoothly removing undesired elements. We will then cover techniques of object tracking, body part recognition, and object recognition using advanced techniques of machine learning such as artificial neural network. 3D reconstruction and augmented reality techniques are also included. The book covers popular OpenCV libraries with the help of examples.

This book is a practical tutorial that covers various examples at different levels, teaching you about the different functions of OpenCV and their actual implementation. By the end of this book, you will have acquired the skills to use OpenCV and Python to develop real-world computer vision applications.

Style and approach

The book is a practical tutorial that covers various examples at different levels, teaching you about the different functions of OpenCV and their actual implementation.

Table of contents

  1. 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
  2. Applying Geometric Transformations to Images
    1. Installing OpenCV-Python
      1. Windows
      2. macOS X
      3. Linux (for Ubuntu)
        1. Virtual environments
          1. Troubleshooting
        2. OpenCV documentation
    2. Reading, displaying, and saving images
      1. What just happened?
    3. Loading and saving an image
      1. Changing image format
    4. Image color spaces
      1. Converting color spaces
        1. What just happened?
      2. Splitting image channels
      3. Merging image channels
    5. Image translation
      1. What just happened?
    6. Image rotation
      1. What just happened?
    7. Image scaling
      1. What just happened?
    8. Affine transformations
      1. What just happened?
    9. Projective transformations
      1. What just happened?
    10. Image warping
    11. Summary
  3. Detecting Edges and Applying Image Filters
    1. 2D convolution
    2. Blurring
      1. Size of the kernel versus blurriness
    3. Motion blur
      1. Under the hood
    4. Sharpening
      1. Understanding the pattern
    5. Embossing
    6. Edge detection
    7. Erosion and dilation
      1. Afterthought
    8. Creating a vignette filter
      1. What's happening underneath?
      2. How do we move the focus around?
    9. Enhancing the contrast in an image
      1. How do we handle color images?
    10. Summary
  4. Cartoonizing an Image
    1. Accessing the webcam
      1. Under the hood
        1. Extending capture options
    2. Keyboard inputs
      1. Interacting with the application
    3. Mouse inputs
      1. What's happening underneath?
    4. Interacting with a live video stream
      1. How did we do it?
    5. Cartoonizing an image
      1. Deconstructing the code
    6. Summary
  5. Detecting and Tracking Different Body Parts
    1. Using Haar cascades to detect things
    2. What are integral images?
    3. Detecting and tracking faces
      1. Understanding it better
    4. Fun with faces
      1. Under the hood
      2. Removing the alpha channel from the overlay image
    5. Detecting eyes
      1. Afterthought
    6. Fun with eyes
      1. Positioning the sunglasses
    7. Detecting ears
    8. Detecting a mouth
    9. It's time for a moustache
    10. Detecting pupils
      1. Deconstructing the code
    11. Summary
  6. Extracting Features from an Image
    1. Why do we care about keypoints?
    2. What are keypoints?
    3. Detecting the corners
    4. Good features to track
    5. Scale-invariant feature transform (SIFT)
    6. Speeded-up robust features (SURF)
    7. Features from accelerated segment test (FAST)
    8. Binary robust independent elementary features (BRIEF)
    9. Oriented FAST and Rotated BRIEF (ORB)
    10. Summary
  7. Seam Carving
    1. Why do we care about seam carving?
    2. How does it work?
    3. How do we define interesting?
    4. How do we compute the seams?
    5. Can we expand an image?
    6. Can we remove an object completely?
      1. How did we do it?
    7. Summary
  8. Detecting Shapes and Segmenting an Image
    1. Contour analysis and shape matching
    2. Approximating a contour
    3. Identifying a pizza with a slice taken out
    4. How to censor a shape?
    5. What is image segmentation?
      1. How does it work?
    6. Watershed algorithm
    7. Summary
  9. Object Tracking
    1. Frame differencing
    2. Colorspace based tracking
    3. Building an interactive object tracker
    4. Feature-based tracking
    5. Background subtraction
    6. Summary
  10. Object Recognition
    1. Object detection versus object recognition
    2. What is a dense feature detector?
    3. What is a visual dictionary?
    4. What is supervised and unsupervised learning?
    5. What are support vector machines?
      1. What if we cannot separate the data with simple straight lines?
    6. How do we actually implement this?
      1. What happened inside the code?
      2. How did we build the trainer?
    7. Summary
  11. Augmented Reality
    1. What is the premise of augmented reality?
    2. What does an augmented reality system look like?
    3. Geometric transformations for augmented reality
    4. What is pose estimation?
    5. How to track planar objects
      1. What happened inside the code?
    6. How to augment our reality
      1. Mapping coordinates from 3D to 2D
      2. How to overlay 3D objects on a video
      3. Let's look at the code
    7. Let's add some movements
    8. Summary
  12. Machine Learning by an Artificial Neural Network
    1. Machine learning (ML) versus artificial neural network (ANN)
    2. How does ANN work?
    3. How to define multi-layer perceptrons (MLP)
    4. How to implement an ANN-MLP classifier? 
      1. Evaluate a trained network
      2. Classifying images
    5. Summary
  13. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: OpenCV 3.x with Python By Example - Second Edition
  • Author(s): Gabriel Garrido, Prateek Joshi
  • Release date: January 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788396905