Book Image

OpenCV 2 Computer Vision Application Programming Cookbook

By : Robert Laganiere
Book Image

OpenCV 2 Computer Vision Application Programming Cookbook

By: Robert Laganiere

Overview of this book

<p>In today's digital world, images are everywhere, and with the advent of powerful and affordable computing devices, it has become possible to create sophisticated applications manipulating images and videos. Adding special effects, enhancing image features, performing object recognition, and reconstructing 3D information are tasks that can be programmed easily with the OpenCV library, which is a widely used open source library that offers a rich set of advanced computer vision algorithms.</p> <p><em>OpenCV 2 Computer Vision Application Programming Cookbook</em> will introduce you to numerous computer vision algorithms included in the OpenCV library. You will learn how to read, write, create and manipulate images. You will explore different techniques commonly used in image analysis and how they can be effectively implemented in C++. The book provides a complete introduction to the OpenCV library and explains how to build your first computer vision program. You will be presented with a variety of computer vision algorithms and be exposed to important concepts in image analysis that will enable you to build your own computer vision applications.</p> <p>The book helps you to get started with the library, showing you how to install and deploy the OpenCV library to write effective computer vision applications following good programming practices. The techniques to process an image and its pixels using the data structures offered by the library are explained in detail. You will learn how to build and manipulate an image histogram; how to detect lines and contours. You will be introduced to the concept of mathematical morphology and image filtering. The detection and use of interest points in computer vision is presented with applications for image matching and object recognition. Techniques to achieve camera calibration and 3D reconstruction are presented.</p> <p><em>OpenCV 2 Computer Vision Application Programming Cookbook</em> is your guide to the development of computer vision applications. It is a comprehensive reference that exposes you to computer vision concepts illustrated with extensive examples.</p>
Table of Contents (17 chapters)
OpenCV 2 Computer Vision Application Programming Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

In today's digital world, images and videos are everywhere, and with the advent of powerful and affordable computing devices, it has never been easier to create sophisticated imaging applications. Plentiful software tools and libraries manipulating images and videos are offered, but for anyone who wishes to develop his/her own applications, the OpenCV library is the tool to use.

OpenCV (Open Source Computer Vision) is an open source library containing more than 500 optimized algorithms for image and video analysis. Since its introduction in 1999, it has been largely adopted as the primary development tool by the community of researchers and developers in computer vision. OpenCV was originally developed at Intel by a team led by Gary Bradski as an initiative to advance research in vision and promote the development of rich, vision-based CPU-intensive applications. After a series of beta releases, version 1.0 was launched in 2006. A second major release occurred in 2009 with the launch of OpenCV 2 that proposed important changes, especially the new C++ interface which we use in this book. At the time of writing, the latest release is 2.2 (December 2010).

This book covers many of the library's features and shows how to use them to accomplish specific tasks. Our objective is not to provide a complete and detailed coverage of every option offered by the OpenCV functions and classes, but rather to give you the elements you need to build your applications from the ground up. In this book we also explore fundamental concepts in image analysis and describe some of the important algorithms in computer vision.

This book is an opportunity for you to get introduced to the world of image and video analysis. But this is just the beginning. The good news is that OpenCV continues to evolve and expand. Just consult the OpenCV online documentation to stay updated about what the library can do for you:

http://opencv.willowgarage.com/wiki/

What this book covers

Chapter 1, Playing with Images, introduces the OpenCV library and shows you how to run simple applications using the MS Visual C++ and Qt development environments.

Chapter 2, Manipulating the Pixels, explains how an image can be read. It describes different methods for scanning an image in order to perform an operation on each of its pixels. You will also learn how to define region of interest inside an image.

Chapter 3, Processing Images with Classes, consists of recipes which present various object-oriented design patterns that can help you to build better computer vision applications.

Chapter 4, Counting the Pixels with Histograms, shows you how to compute image histograms and how they can be used to modify an image. Different applications based on histograms are presented that achieve image segmentation, object detection, and image retrieval.

Chapter 5, Transforming Images with Morphological Operations, explores the concept of mathematical morphology. It presents different operators and how they can be used to detect edges, corners, and segments in images.

Chapter 6, Filtering the Images, teaches you the principle of frequency analysis and image filtering. It shows how low-pass and high-pass filters can be applied to images. It presents the two image derivative operators: the gradient and the Laplacian.

Chapter 7, Extracting Lines, Contours, and Components, focuses on the detection of geometric image features. It explains how to extract contours, lines, and connected components in an image.

Chapter 8, Detecting and Matching Interest Points, describes various feature point detectors in images. It also explains how descriptors of interest points can be computed and used to match points between images.

Chapter 9, Estimating Projective Relations in Images, analyzes the different relations involved in image formation. It also explores the projective relations that exist between two images of a same scene.

Chapter 10, Processing Video Sequences, provides a framework to read and write a video sequence and to process its frames. It also shows you how it is possible to track feature points from frame to frame, and how to extract the foreground objects moving in front of a camera.

Who this book is for

If you are a novice C++ programer who wants to learn how to use the OpenCV library to build computer vision applications, then this cookbook is appropriate for you. It is also suitable for professional software developers wishing to be introduced to the concepts of computer vision programming. It can be used as a companion book in university-level computer vision courses. It constitutes an excellent reference for graduate students and researchers in image processing and computer vision. The book provides a good combination of basic to advanced recipes. Basic knowledge of C++ is required.

Conventions

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

Code words in text are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

     // get the iterators
     cv::Mat_<cv::Vec3b>::const_iterator it=
                         image.begin<cv::Vec3b>();

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

     // Converting to Lab color space 
     cv::cvtColor(image, converted, CV_BGR2Lab);
     // get the iterators of the converted image 
     cv::Mat_<cv::Vec3b>::iterator it= 

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "This value is read when the Process button is clicked, which also triggers the processing and displays the result".

Note

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 may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

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 on 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 for all Packt books you have purchased from your account at http://www.PacktPub.com. 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.

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 would 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/support, 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 on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright 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

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.