Chapter 1. Setting Up OpenCV
You picked up this book so you may already have an idea of what OpenCV is. Maybe, you heard of Sci-Fi-sounding features, such as face detection, and got intrigued. If this is the case, you've made the perfect choice. OpenCV stands for Open Source Computer Vision. It is a free computer vision library that allows you to manipulate images and videos to accomplish a variety of tasks from displaying the feed of a webcam to potentially teaching a robot to recognize real-life objects.
In this book, you will learn to leverage the immense potential of OpenCV with the Python programming language. Python is an elegant language with a relatively shallow learning curve and very powerful features. This chapter is a quick guide to setting up Python 2.7, OpenCV, and other related libraries. After setup, we also look at OpenCV's Python sample scripts and documentation.
Note
If you wish to skip the installation process and jump right into action, you can download the virtual machine (VM) I've made available at http://techfort.github.io/pycv/.
This file is compatible with VirtualBox, a free-to-use virtualization application that lets you build and run VMs. The VM I've built is based on Ubuntu Linux 14.04 and has all the necessary software installed so that you can start coding right away.
This VM requires at least 2 GB of RAM to run smoothly, so make sure that you allocate at least 2 (but, ideally, more than 4) GB of RAM to the VM, which means that your host machine will need at least 6 GB of RAM to sustain it.
The following related libraries are covered in this chapter:
- NumPy: This library is a dependency of OpenCV's Python bindings. It provides numeric computing functionality, including efficient arrays.
- SciPy: This library is a scientific computing library that is closely related to NumPy. It is not required by OpenCV, but it is useful for manipulating data in OpenCV images.
- OpenNI: This library is an optional dependency of OpenCV. It adds the support for certain depth cameras, such as Asus XtionPRO.
- SensorKinect: This library is an OpenNI plugin and optional dependency of OpenCV. It adds support for the Microsoft Kinect depth camera.
For this book's purposes, OpenNI and SensorKinect can be considered optional. They are used throughout Chapter 4, Depth Estimation and Segmentation, but are not used in the other chapters or appendices.
Note
This book focuses on OpenCV 3, the new major release of the OpenCV library. All additional information about OpenCV is available at http://opencv.org, and its documentation is available at http://docs.opencv.org/master.