Book Image

IPython Interactive Computing and Visualization Cookbook

By : Cyrille Rossant
Book Image

IPython Interactive Computing and Visualization Cookbook

By: Cyrille Rossant

Overview of this book

Table of Contents (22 chapters)
IPython Interactive Computing and Visualization Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Detecting faces in an image with OpenCV


OpenCV (Open Computer Vision) is an open source C++ library for computer vision. It features algorithms for image segmentation, object recognition, augmented reality, face detection, and other computer vision tasks.

In this recipe, we will use OpenCV in Python to detect faces in a picture.

Getting ready

You need OpenCV and the Python wrapper. You can find installation instructions on OpenCV's website, http://docs.opencv.org/trunk/doc/py_tutorials/py_tutorials.html.

On Windows, you can install Chris Gohlke's package, available at www.lfd.uci.edu/~gohlke/pythonlibs/#opencv.

You also need to download the Family dataset from the book's GitHub repository at https://github.com/ipython-books/cookbook-data.

Note

OpenCV is not compatible with Python 3 at the time of this writing. Therefore, this recipe requires Python 2.

How to do it...

  1. First, we import the packages:

    In [1]: import numpy as np
            import cv2
            import matplotlib.pyplot as plt
            %matplotlib...