Book Image

OpenCV with Python By Example

By : Prateek Joshi
Book Image

OpenCV with Python By Example

By: Prateek Joshi

Overview of this book

Table of Contents (19 chapters)
OpenCV with Python By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

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 is a practical tutorial that covers various examples at different levels, teaching you about the different functions of OpenCV and their actual implementations.

What this book covers

Chapter 1, Applying Geometric Transformations to Images, explains how to apply geometric transformations to images. In this chapter, we will discuss affine and projective transformations, and see how we can use them to apply cool geometric effects to photos. The chapter will begin with the procedure to install OpenCV-Python on multiple platforms such as Mac OS X, Linux, and Windows. We will also learn how to manipulate an image in various ways, such as resizing, changing color spaces, and so on.

Chapter 2, Detecting Edges and Applying Image Filters, shows how to use fundamental image-processing operators and how we can use them to build bigger projects. We will discuss why we need edge detection and how it can be used in various different ways in computer vision applications. We will discuss image filtering and how we can use it to apply various visual effects to photos.

Chapter 3, Cartoonizing an Image, shows how to cartoonize a given image using image filters and other transformations. We will see how to use the webcam to capture a live video stream. We will discuss how to build a real-time application, where we extract information from each frame in the stream and display the result.

Chapter 4, Detecting and Tracking Different Body Parts, shows how to detect and track faces in a live video stream. We will discuss the face detection pipeline and see how we can use it to detect and track different body parts, such as eyes, ears, mouth, nose, and so on.

Chapter 5, Extracting Features from an Image, is about detecting the salient points (called keypoints) in an image. We will discuss why these salient points are important and how we can use them to understand the image content. We will talk about the different techniques that can be used to detect salient points and extract features from an image.

Chapter 6, Creating a Panoramic Image, shows how to create a panoramic image by stitching multiple images of the same scene together.

Chapter 7, Seam Carving, shows how to do content-aware image resizing. We will discuss how to detect "interesting" parts in an image and see how we can resize a given image without deteriorating those interesting parts.

Chapter 8, Detecting Shapes and Segmenting an Image, shows how to perform image segmentation. We will discuss how to partition a given image into its constituent parts in the best possible way. You will also learn how to separate the foreground from the background in an image.

Chapter 9, Object Tracking, shows you how to track different objects in a live video stream. At the end of this chapter, you will be able to track any object in a live video stream that is captured through the webcam.

Chapter 10, Object Recognition, shows how to build an object recognition system. We will discuss how to use this knowledge to build a visual search engine.

Chapter 11, Stereo Vision and 3D Reconstruction, shows how to reconstruct the depth map using stereo images. You will learn how to achieve a 3D reconstruction of a scene from a set of images.

Chapter 12, Augmented Reality, shows how to build an augmented reality application. By the end of this chapter, you will be able to build a fun augmented reality project using the webcam.

What you need for this book

You'll need the following software:

  • OpenCV 2.4.9

  • numpy 1.9.2

  • scipy 0.15.1

  • scikit-learn 0.16.1

The hardware specifications requirement is any computer with at least 4GB DDR3 RAM.

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.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We use a function called getPerspectiveTransform to get the transformation matrix."

A block of code is set as follows:

cv2.imshow('Input', img)
cv2.imshow('Output', img_output)
cv2.waitKey()

Any command-line input or output is written as follows:

$ make -j4
$ sudo make install

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "The tx and ty values are the X and Y translation values."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. 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.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/B04554_Graphics.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.