O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

OpenCV Computer Vision with Python

Book Description

Learn to capture videos, manipulate images and track objects with Python using the OpenCV Library

  • Set up OpenCV, its Python bindings, and optional Kinect drivers on Windows, Mac or Ubuntu
  • Create an application that tracks and manipulates faces
  • Identify face regions using normal color images and depth images

In Detail

Computer Vision can reach consumers in various contexts via webcams, camera phones and gaming sensors like Kinect. OpenCV's Python bindings can help developers meet these consumer demands for applications that capture images, change their appearance and extract information from them, in a high-level language and in a standardized data format that is interoperable with scientific libraries such as NumPy and SciPy.

"OpenCV Computer Vision with Python" is a practical, hands-on guide that covers the fundamental tasks of computer vision—capturing, filtering and analyzing images—with step-by-step instructions for writing both an application and reusable library classes.

"OpenCV Computer Vision with Python" shows you how to use the Python bindings for OpenCV. By following clear and concise examples you will develop a computer vision application that tracks faces in live video and applies special effects to them. If you have always wanted to learn which version of these bindings to use, how to integrate with cross-platform Kinect drivers and and how to efficiently process image data with NumPy and SciPy then this book is for you.

Table of Contents

  1. OpenCV Computer Vision with Python
    1. Table of Contents
    2. OpenCV Computer Vision with Python
    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. Setting up OpenCV
      1. Choosing and using the right setup tools
        1. Making the choice on Windows XP, Windows Vista, Windows 7, or Windows 8
          1. Using binary installers (no support for depth cameras)
          2. Using CMake and compilers
        2. Making the choice on Mac OS X Snow Leopard, Mac OS X Lion, or Mac OS X Mountain Lion
          1. Using MacPorts with ready-made packages
          2. Using MacPorts with your own custom packages
          3. Using Homebrew with ready-made packages (no support for depth cameras)
          4. Using Homebrew with your own custom packages
        3. Making the choice on Ubuntu 12.04 LTS or Ubuntu 12.10
          1. Using the Ubuntu repository (no support for depth cameras)
          2. Using CMake via a ready-made script that you may customize
        4. Making the choice on other Unix-like systems
      2. Running samples
      3. Finding documentation, help, and updates
      4. Summary
    9. 2. Handling Files, Cameras, and GUIs
      1. Basic I/O scripts
        1. Reading/Writing an image file
        2. Converting between an image and raw bytes
        3. Reading/Writing a video file
        4. Capturing camera frames
        5. Displaying camera frames in a window
      2. Project concept
      3. An object-oriented design
        1. Abstracting a video stream – managers.CaptureManager
        2. Abstracting a window and keyboard – managers.WindowManager
        3. Applying everything – cameo.Cameo
      4. Summary
    10. 3. Filtering Images
      1. Creating modules
      2. Channel mixing – seeing in Technicolor
        1. Simulating RC color space
        2. Simulating RGV color space
        3. Simulating CMV color space
      3. Curves – bending color space
        1. Formulating a curve
        2. Caching and applying a curve
        3. Designing object-oriented curve filters
        4. Emulating photo films
          1. Emulating Kodak Portra
          2. Emulating Fuji Provia
          3. Emulating Fuji Velvia
          4. Emulating cross-processing
      4. Highlighting edges
      5. Custom kernels – getting convoluted
      6. Modifying the application
      7. Summary
    11. 4. Tracking Faces with Haar Cascades
      1. Conceptualizing Haar cascades
      2. Getting Haar cascade data
      3. Creating modules
      4. Defining a face as a hierarchy of rectangles
      5. Tracing, cutting, and pasting rectangles
      6. Adding more utility functions
      7. Tracking faces
      8. Modifying the application
        1. Swapping faces in one camera feed
        2. Copying faces between camera feeds
      9. Summary
    12. 5. Detecting Foreground/Background Regions and Depth
      1. Creating modules
      2. Capturing frames from a depth camera
      3. Creating a mask from a disparity map
      4. Masking a copy operation
      5. Modifying the application
      6. Summary
    13. A. Integrating with Pygame
      1. Installing Pygame
      2. Documentation and tutorials
      3. Subclassing managers.WindowManager
      4. Modifying the application
      5. Further uses of Pygame
      6. Summary
    14. B. Generating Haar Cascades for Custom Targets
      1. Gathering positive and negative training images
      2. Finding the training executables
        1. On Windows
        2. On Mac, Ubuntu, and other Unix-like systems
      3. Creating the training sets and cascade
        1. Creating <negative_description>
        2. Creating <positive_description>
        3. Creating <binary_description> by running <opencv_createsamples>
        4. Creating <cascade> by running <opencv_traincascade>
      4. Testing and improving <cascade>
      5. Summary
    15. Index