You are previewing OpenCV Computer Vision Application Programming Cookbook Second Edition.
O'Reilly logo
OpenCV Computer Vision Application Programming Cookbook Second Edition

Book Description

Over 50 recipes to help you build computer vision applications in C++ using the OpenCV library

In Detail

OpenCV Computer Vision Application Programming Cookbook Second Edition is your guide to the development of computer vision applications.

The book shows you how to install and deploy the OpenCV library to write an effective computer vision application. Different techniques for image enhancement, pixel manipulation, and shape analysis will be presented. You will also learn how to process video from files or cameras and detect and track moving objects. You will also be introduced to recent approaches in machine learning and object classification.

This book is a comprehensive reference guide that exposes you to practical and fundamental computer vision concepts, illustrated by extensive examples.

What You Will Learn

  • Install and create a program using the OpenCV library
  • Process an image by manipulating its pixels
  • Analyze an image using histograms
  • Segment images into homogenous regions and extract meaningful objects
  • Apply image filters to enhance image content
  • Exploit image geometry in order to relate different views of a pictured scene
  • Calibrate the camera from different image observations
  • Detect faces and people in images using machine learning techniques
  • 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 files e-mailed directly to you.

    Table of Contents

    1. OpenCV Computer Vision Application Programming Cookbook Second Edition
      1. Table of Contents
      2. OpenCV Computer Vision Application Programming Cookbook Second Edition
      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
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Playing with Images
        1. Introduction
        2. 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
        3. 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
        4. 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
            2. The old IplImage structure
          4. See also
        5. 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
      9. 2. Manipulating Pixels
        1. Introduction
        2. 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
        3. 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
        4. Scanning an image with iterators
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Writing efficient image-scanning loops
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        6. 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
        7. 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
        8. Remapping an image
          1. How to do it...
          2. How it works...
          3. See also
      10. 3. Processing Color Images with Classes
        1. Introduction
        2. Using the Strategy pattern in an algorithm design
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Computing the distance between two color vectors
            2. Using OpenCV functions
            3. The functor or function object
          5. See also
        3. Using a Controller design pattern to communicate with processing modules
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. The Model-View-Controller architecture
        4. Converting color representations
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        5. 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
      11. 4. Counting the Pixels with Histograms
        1. Introduction
        2. 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
        3. Applying look-up tables to modify the image 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 look-up table on color images
          4. See also
        4. Equalizing the image histogram
          1. How to do it...
          2. How it works...
        5. 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
          4. See also
        6. Using the mean shift algorithm to find an object
          1. How to do it...
          2. How it works...
          3. See also
        7. Retrieving similar images using the histogram comparison
          1. How to do it...
          2. How it works...
          3. See also
        8. 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
      12. 5. Transforming Images with Morphological Operations
        1. Introduction
        2. 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
        3. Opening and closing images using morphological filters
          1. How to do it...
          2. How it works...
          3. See also
        4. Detecting edges and corners using morphological filters
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. Segmenting images using watersheds
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        6. Extracting distinctive regions using MSER
          1. How to do it...
          2. How it works...
          3. See also
        7. Extracting foreground objects with the GrabCut algorithm
          1. How to do it...
          2. How it works...
          3. See also
      13. 6. Filtering the Images
        1. Introduction
        2. Filtering images using low-pass filters
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Downsampling an image
            2. 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
      14. 7. Extracting Lines, Contours, and Components
        1. Introduction
        2. Detecting image contours with the Canny operator
          1. How to do it...
          2. How it works...
          3. See also
        3. 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
        4. Fitting a line to a set of points
          1. How to do it...
          2. How it works...
          3. There's more...
        5. Extracting the components' contours
          1. How to do it...
          2. How it works...
          3. There's more...
        6. Computing components' shape descriptors
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Quadrilateral detection
      15. 8. Detecting Interest Points
        1. Introduction
        2. 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
        3. Detecting features quickly
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Adapted feature detection
            2. Grid adapted feature detection
            3. Pyramid adapted feature detection
          4. See also
        4. 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
        5. 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
      16. 9. Describing and Matching Interest Points
        1. Introduction
        2. Matching local templates
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Template matching
          4. See also
        3. 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
        4. Describing keypoints with binary features
          1. How to do it...
          2. How it works...
          3. There's more...
            1. FREAK
          4. See also
      17. 10. Estimating Projective Relations in Images
        1. Introduction
          1. Image formation
        2. Calibrating a camera
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Calibration with known intrinsic parameters
            2. Using a grid of circles for calibration
          4. See also
        3. Computing the fundamental matrix of an image pair
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        4. 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
        5. Computing a homography between two images
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Detecting planar targets in an image
          5. See also
      18. 11. Processing Video Sequences
        1. Introduction
        2. Reading video sequences
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Processing the 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
        4. 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
        5. Tracking feature points in a video
          1. How to do it...
          2. How it works...
          3. See also
        6. 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
      19. Index