OpenCV with Python By Example

Book description

Build real-world computer vision applications and develop cool demos using OpenCV for Python

About This Book

  • Learn how to apply complex visual effects to images using geometric transformations and image filters
  • Extract features from an image and use them to develop advanced applications
  • Build algorithms to help you understand the image content and perform visual searches

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-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

  • Apply geometric transformations to images, perform image filtering, and convert an image into a cartoon-like image
  • Detect and track various body parts such as the face, nose, eyes, ears, and mouth
  • Stitch multiple images of a scene together to create a panoramic image
  • Make an object disappear from an image
  • Identify different shapes, segment an image, and track an object in a live video
  • Recognize an object in an image and build a visual search engine
  • Reconstruct a 3D map from images
  • Build an augmented reality application

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 are getting more processing power to work with. Using this technology, we can seamlessly integrate our computer vision applications into the cloud. Web developers can develop complex applications without having to reinvent the wheel.

This book will walk you through all the building blocks needed to build amazing computer vision applications with ease. We start off with applying geometric transformations to images. We then discuss affine and projective transformations and see how we can use them to apply cool geometric effects to photos. We will then cover techniques used for object recognition, 3D reconstruction, stereo imaging, and other computer vision applications.

This book will also provide clear examples written in Python to build OpenCV applications. The book starts off with simple beginner's level tasks such as basic processing and handling images, image mapping, and detecting images. It also covers popular OpenCV libraries with the help of examples.

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.

Style and approach

This is a conversational-style book filled with hands-on examples that are really easy to understand. Each topic is explained very clearly and is followed by a programmatic implementation so that the concept is solidified. Each topic contributes to something bigger in the following chapters, which helps you understand how to piece things together to build something big and complex.

Table of contents

  1. OpenCV with Python By Example
    1. Table of Contents
    2. OpenCV with Python By Example
    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. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Applying Geometric Transformations to Images
      1. Installing OpenCV-Python
        1. Windows
        2. Mac OS X
        3. Linux (for Ubuntu)
      2. Reading, displaying, and saving images
        1. What just happened?
        2. Loading and saving an image
      3. Image color spaces
        1. Converting between color spaces
        2. What just happened?
      4. Image translation
        1. What just happened?
      5. Image rotation
        1. What just happened?
      6. Image scaling
        1. What just happened?
      7. Affine transformations
        1. What just happened?
      8. Projective transformations
        1. What just happened?
      9. Image warping
      10. Summary
    9. 2. Detecting Edges and Applying Image Filters
      1. 2D convolution
      2. Blurring
        1. The size of the kernel versus the blurriness
      3. Edge detection
      4. Motion blur
        1. Under the hood
      5. Sharpening
        1. Understanding the pattern
      6. Embossing
      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
    10. 3. Cartoonizing an Image
      1. Accessing the webcam
        1. Under the hood
      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
    11. 4. 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
      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 a nose
      11. Detecting pupils
        1. Deconstructing the code
      12. Summary
    12. 5. 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
    13. 6. Creating a Panoramic Image
      1. Matching keypoint descriptors
        1. How did we match the keypoints?
        2. Understanding the matcher object
        3. Drawing the matching keypoints
      2. Creating the panoramic image
        1. Finding the overlapping regions
        2. Stitching the images
      3. What if the images are at an angle to each other?
        1. Why does it look stretched?
      4. Summary
    14. 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
    15. 8. Detecting Shapes and Segmenting an Image
      1. Contour analysis and shape matching
      2. Approximating a contour
      3. Identifying the pizza with the slice taken out
      4. How to censor a shape?
      5. What is image segmentation?
        1. How does it work?
      6. Watershed algorithm
      7. Summary
    16. 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
    17. 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
    18. 11. Stereo Vision and 3D Reconstruction
      1. What is stereo correspondence?
      2. What is epipolar geometry?
        1. Why are the lines different as compared to SIFT?
      3. Building the 3D map
      4. Summary
    19. 12. 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
    20. Index

Product information

  • Title: OpenCV with Python By Example
  • Author(s): Prateek Joshi
  • Release date: September 2015
  • Publisher(s): Packt Publishing
  • ISBN: 9781785283932