Table Of Contentwww.it-ebooks.info
OpenCV By Example
Enhance your understanding of Computer Vision and
image processing by developing real-world projects in
OpenCV 3
Prateek Joshi
David Millán Escrivá
Vinícius Godoy
BIRMINGHAM - MUMBAI
www.it-ebooks.info
OpenCV By Example
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the authors, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
First published: January 2016
Production reference: 1150116
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-094-8
www.packtpub.com
www.it-ebooks.info
Credits
Authors Copy Editor
Prateek Joshi Rashmi Sawant
David Millán Escrivá
Vinícius Godoy Project Coordinator
Suzanne Coutinho
Reviewers
Emmanuel d'Angelo Proofreader
Sais Editing
Dr. Bryan Wai-ching CHUNG
Nikolaus Gradwohl
Indexer
Luis Díaz Más
Hemangini Bari
Commissioning Editor
Graphics
Ashwin Nair
Kirk D'Penha
Acquisition Editor
Production Coordinator
Tushar Gupta
Shantanu N. Zagade
Content Development Editor
Cover Work
Amey Varangaonkar
Shantanu N. Zagade
Technical Editor
Naveenkumar Jain
www.it-ebooks.info
About the Authors
Prateek Joshi is a Computer Vision researcher and published author. He has over
eight years of experience in this ield with a primary focus on content-based analysis
and deep learning. His work in this ield has resulted in multiple patents, tech
demos, and research papers at major IEEE conferences. He is the author of OpenCV
with Python By Example, Packt Publishing.
He has won many hackathons using a wide variety of technologies related to image
recognition. His blog has been visited by users in more than 200 countries, and he
has been featured as a guest author in prominent tech magazines. He enjoys blogging
on topics, such as artiicial intelligence, abstract mathematics, and cryptography. You
can visit his blog at www.prateekvjoshi.com.
He is an avid coder who is passionate about building game-changing products. He
is particularly interested in intelligent algorithms that can automatically understand
the content to produce scene descriptions in terms of constituent objects. He
graduated from the University of Southern California and has worked for such
companies as Nvidia, Microsoft Research, Qualcomm, and a couple of early stage
start-ups in Silicon Valley. You can learn more about him on his personal website at
www.prateekj.com.
I would like to thank the reviewers for helping me reine this book.
I would also like to thank Packt Publishing for publishing this book.
Finally, I would like to thank my family for supporting me through
everything.
www.it-ebooks.info
David Millán Escrivá was eight years old when he wrote his irst program on an
8086 PC with BASIC language, which enabled the 2D plotting of BASIC equations.
He started with his computer development relationship and created many
applications and games.
In 2005, he completed his studies in IT from the Universitat Politécnica de Valencia
with honors in human-computer interaction supported by Computer Vision with
OpenCV (v0.96). He had a inal project based on this subject and published it on HCI
Spanish Congress.
In 2014, he completed his Master's degree in artiicial intelligence, computer
graphics, and pattern recognition, focusing on pattern recognition and
Computer Vision.
He participated in Blender source code, an open source and 3D-software project, and
worked in his irst commercial movie, Plumiferos—Aventuras voladoras, as a computer
graphics software developer.
David now has more than 13 years of experience in IT, with more than nine years
of experience in Computer Vision, computer graphics, and pattern recognition,
working on different projects and start-ups, applying his knowledge of Computer
Vision, optical character recognition, and augmented reality.
He is the author of the DamilesBlog (http://blog.damiles.com), where he
publishes research articles and tutorials on OpenCV, Computer Vision in general,
and optical character recognition algorithms. He is the co-author of Mastering
OpenCV with Practical Computer Vision Projects Book and also the reviewer of GnuPlot
Cookbook by Lee Phillips, OpenCV Computer Vision with Python by Joseph Howse, Instant
Opencv Starter by Jayneil Dalal and Sohil Patel, all published by Packt Publishing.
I would like thank to my wife, Izaskun, my daughter, Eider, and my
son, Pau, for their unlimited patience and support in all moments.
They have changed my life and made it awesome. Love you all.
I would like to thank the OpenCV team and community that gives
us this wonderful library. I would also like to thank my co-authors
and Packt Publishing for supporting me and helping me complete
this book.
www.it-ebooks.info
Vinícius Godoy is a computer graphics university professor at PUCPR. He started
programming with C++ 18 years ago and ventured into the ield of computer gaming
and computer graphics 10 years ago. His former experience also includes working
as an IT manager in document processing applications in Sinax, a company that
focuses in BPM and ECM activities, building games and applications for Positivo
Informática, including building an augmented reality educational game exposed at
CEBIT and network libraries for Siemens Enterprise Communications (Unify).
As part of his Master's degree research, he used Kinect, OpenNI, and OpenCV to
recognize Brazilian sign language gestures. He is currently working with medical
imaging systems for his PhD thesis. He was also a reviewer of the OpenNI Cookbook,
Packt Publishing.
He is also a game development fan, having a popular site entirely dedicated to the
ield called Ponto V (http://www.pontov.com.br). He is the cofounder of a start-
up company called Blackmuppet. His ields of interest includes image processing,
Computer Vision, design patterns, and multithreaded applications.
I would like to thank my wife, who supported me while writing this
book. Her incentive and cooperation was decisive.
I would also like to thank Fabio Binder, a teacher who introduced
me to computer graphics and gaming ields, which greatly helped
me in my computer programming career and brought me to PUCPR,
where I had access to several computer graphics-related software.
www.it-ebooks.info
About the Reviewers
Emmanuel d'Angelo is a photography enthusiast, who managed to make his
way in the image processing ield. After several years of working as a consultant
on various image-related high-tech projects, he is now working as a developer in
a photogrammetry start-up. You can ind image-related thoughts and code on his
technical blog at http://www.computersdontsee.net.
Dr. Bryan, Wai-ching CHUNG is an interactive media artist and design
consultant who lives in Hong Kong. His artworks have been exhibited at the
World Wide Video Festival, Multimedia Art Asia Paciic, Stuttgart Film Winter
Festival, Microwave International New Media Arts Festival, and the China Media
Art Festival. In the former Shanghai Expo 2010, he provided interactive design
consultancy to various industry leaders in Hong Kong and China. He studied
computer science in Hong Kong, interactive multimedia in London, and ine art
in Melbourne. He also develops software libraries for the popular open source
programming language, Processing. He is the author of the book, Multimedia
Programming with Pure Data. Currently, he is working as an assistant professor in the
Academy of Visual Arts, Hong Kong Baptist University, where he teaches subjects
on interactive arts, computer graphics, and multimedia. His website is http://www.
magicandlove.com.
www.it-ebooks.info
Nikolaus Gradwohl was born in 1976 in Vienna, Austria, and always wanted
to become an inventor like Gyro Gearloose. When he got his irst Atari, he igured
out that being a computer programmer was the closest he could get to that dream.
He wrote programs for nearly anything that can be programmed, ranging from an
8-bit microcontroller to mainframes for a living. In his free time, he likes to gain
knowledge of programming languages and operating systems.
He is the author of Processing 2: Creative Coding Hotshot, Packt Publishing.
You can see some of his work on his blog at http://www.local-guru.net/.
Luis Díaz Más is a C++ software engineer currently working at Pix4D, where
he plays the role of a software architect and develops image processing algorithms
that are oriented toward photogrammetry and terrain mapping. He received his
PhD in computer science from the University of Cordoba (Spain) that focuses on 3D
reconstructions and action recognition. Earlier, he worked for CATEC, a research
center for advanced aerospace technologies, where he developed the sensorial
systems for UAS (Unmanned Aerial Systems). He has reviewed other OpenCV
books published by Packt, and he is continuously looking forward to gaining more
knowledge of different topics, such as modern C++ 11/14, Python, CUDA, OpenCL,
and so on.
I would like to thank my parents for always supporting me and
giving me the freedom to do what I like the most in this life. I would
also like to thank my thesis directors, Rafa and Paco, who helped me
in my scientiic career and from whom I have learned a lot. Finally, a
special mention to Celia, the woman who chose to share her life with
this software freak and the one who continuously reminds me that
there are more things in life apart from programming.
www.it-ebooks.info
www.PacktPub.com
Support iles, eBooks, discount offers, and more
For support iles and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF
and ePub iles available? You can upgrade to the eBook version at www.PacktPub.com
and as a print book customer, you are entitled to a discount on the eBook copy. Get in
touch with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign
up for a range of free newsletters and receive exclusive discounts and offers on Packt
books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser
Free access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view 9 entirely free books. Simply use your login credentials for
immediate access.
www.it-ebooks.info