OpenCV with Python Blueprints

Book description

Design and develop advanced computer vision projects using OpenCV with Python

About This Book

  • Program advanced computer vision applications in Python using different features of the OpenCV library
  • Practical end-to-end project covering an important computer vision problem
  • All projects in the book include a step-by-step guide to create computer vision applications

Who This Book Is For

This book is for intermediate users of OpenCV who aim to master their skills by developing advanced practical applications. Readers are expected to be familiar with OpenCV's concepts and Python libraries. Basic knowledge of Python programming is expected and assumed.

What You Will Learn

  • Generate real-time visual effects using different filters and image manipulation techniques such as dodging and burning
  • Recognize hand gestures in real time and perform hand-shape analysis based on the output of a Microsoft Kinect sensor
  • Learn feature extraction and feature matching for tracking arbitrary objects of interest
  • Reconstruct a 3D real-world scene from 2D camera motion and common camera reprojection techniques
  • Track visually salient objects by searching for and focusing on important regions of an image
  • Detect faces using a cascade classifier and recognize emotional expressions in human faces using multi-layer peceptrons (MLPs)
  • Recognize street signs using a multi-class adaptation of support vector machines (SVMs)
  • Strengthen your OpenCV2 skills and learn how to use new OpenCV3 features

In Detail

OpenCV is a native cross platform C++ Library for computer vision, machine learning, and image processing. It is increasingly being adopted in Python for development. OpenCV has C++/C, Python, and Java interfaces with support for Windows, Linux, Mac, iOS, and Android. Developers using OpenCV build applications to process visual data; this can include live streaming data from a device like a camera, such as photographs or videos. OpenCV offers extensive libraries with over 500 functions

This book demonstrates how to develop a series of intermediate to advanced projects using OpenCV and Python, rather than teaching the core concepts of OpenCV in theoretical lessons. Instead, the working projects developed in this book teach the reader how to apply their theoretical knowledge to topics such as image manipulation, augmented reality, object tracking, 3D scene reconstruction, statistical learning, and object categorization.

By the end of this book, readers will be OpenCV experts whose newly gained experience allows them to develop their own advanced computer vision applications.

Style and approach

This book covers independent hands-on projects that teach important computer vision concepts like image processing and machine learning for OpenCV with multiple examples.

Table of contents

  1. OpenCV with Python Blueprints
    1. Table of Contents
    2. OpenCV with Python Blueprints
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
      7. Downloading the color images of this book
        1. Errata
        2. Piracy
        3. Questions
    8. 1. Fun with Filters
      1. Planning the app
      2. Creating a black-and-white pencil sketch
        1. Implementing dodging and burning in OpenCV
        2. Pencil sketch transformation
      3. Generating a warming/cooling filter
        1. Color manipulation via curve shifting
        2. Implementing a curve filter by using lookup tables
        3. Designing the warming/cooling effect
      4. Cartoonizing an image
        1. Using a bilateral filter for edge-aware smoothing
        2. Detecting and emphasizing prominent edges
        3. Combining colors and outlines to produce a cartoon
      5. Putting it all together
        1. Running the app
        2. The GUI base class
          1. The GUI constructor
          2. Handling video streams
          3. A basic GUI layout
        3. A custom filter layout
      6. Summary
    9. 2. Hand Gesture Recognition Using a Kinect Depth Sensor
      1. Planning the app
      2. Setting up the app
        1. Accessing the Kinect 3D sensor
        2. Running the app
        3. The Kinect GUI
      3. Tracking hand gestures in real time
      4. Hand region segmentation
        1. Finding the most prominent depth of the image center region
        2. Applying morphological closing to smoothen the segmentation mask
        3. Finding connected components in a segmentation mask
      5. Hand shape analysis
        1. Determining the contour of the segmented hand region
        2. Finding the convex hull of a contour area
        3. Finding the convexity defects of a convex hull
      6. Hand gesture recognition
        1. Distinguishing between different causes of convexity defects
        2. Classifying hand gestures based on the number of extended fingers
      7. Summary
    10. 3. Finding Objects via Feature Matching and Perspective Transforms
      1. Tasks performed by the app
      2. Planning the app
      3. Setting up the app
        1. Running the app
        2. The FeatureMatching GUI
      4. The process flow
      5. Feature extraction
        1. Feature detection
        2. Detecting features in an image with SURF
      6. Feature matching
        1. Matching features across images with FLANN
        2. The ratio test for outlier removal
        3. Visualizing feature matches
        4. Homography estimation
        5. Warping the image
      7. Feature tracking
        1. Early outlier detection and rejection
      8. Seeing the algorithm in action
      9. Summary
    11. 4. 3D Scene Reconstruction Using Structure from Motion
      1. Planning the app
      2. Camera calibration
        1. The pinhole camera model
        2. Estimating the intrinsic camera parameters
          1. The camera calibration GUI
          2. Initializing the algorithm
          3. Collecting image and object points
          4. Finding the camera matrix
      3. Setting up the app
        1. The main function routine
        2. The SceneReconstruction3D class
      4. Estimating the camera motion from a pair of images
        1. Point matching using rich feature descriptors
        2. Point matching using optic flow
        3. Finding the camera matrices
        4. Image rectification
      5. Reconstructing the scene
      6. 3D point cloud visualization
      7. Summary
    12. 5. Tracking Visually Salient Objects
      1. Planning the app
      2. Setting up the app
        1. The main function routine
        2. The Saliency class
        3. The MultiObjectTracker class
      3. Visual saliency
        1. Fourier analysis
        2. Natural scene statistics
        3. Generating a Saliency map with the spectral residual approach
        4. Detecting proto-objects in a scene
      4. Mean-shift tracking
        1. Automatically tracking all players on a soccer field
        2. Extracting bounding boxes for proto-objects
        3. Setting up the necessary bookkeeping for mean-shift tracking
        4. Tracking objects with the mean-shift algorithm
      5. Putting it all together
      6. Summary
    13. 6. Learning to Recognize Traffic Signs
      1. Planning the app
      2. Supervised learning
        1. The training procedure
        2. The testing procedure
        3. A classifier base class
      3. The GTSRB dataset
        1. Parsing the dataset
      4. Feature extraction
        1. Common preprocessing
        2. Grayscale features
        3. Color spaces
        4. Speeded Up Robust Features
        5. Histogram of Oriented Gradients
      5. Support Vector Machine
        1. Using SVMs for Multi-class classification
        2. Training the SVM
        3. Testing the SVM
          1. Confusion matrix
          2. Accuracy
          3. Precision
          4. Recall
      6. Putting it all together
      7. Summary
    14. 7. Learning to Recognize Emotions on Faces
      1. Planning the app
      2. Face detection
        1. Haar-based cascade classifiers
        2. Pre-trained cascade classifiers
        3. Using a pre-trained cascade classifier
        4. The FaceDetector class
          1. Detecting faces in grayscale images
          2. Preprocessing detected faces
      3. Facial expression recognition
        1. Assembling a training set
          1. Running the screen capture
          2. The GUI constructor
          3. The GUI layout
          4. Processing the current frame
          5. Adding a training sample to the training set
          6. Dumping the complete training set to a file
        2. Feature extraction
          1. Preprocessing the dataset
          2. Principal component analysis
        3. Multi-layer perceptrons
          1. The perceptron
          2. Deep architectures
        4. An MLP for facial expression recognition
          1. Training the MLP
          2. Testing the MLP
          3. Running the script
      4. Putting it all together
        1. Summary
    15. Index

Product information

  • Title: OpenCV with Python Blueprints
  • Author(s): Michael Beyeler
  • Release date: October 2015
  • Publisher(s): Packt Publishing
  • ISBN: 9781785282690