Book Image

Building Computer Vision Projects with OpenCV 4 and C++

By : David Millán Escrivá, Prateek Joshi, Vinícius G. Mendonça, Roy Shilkrot
Book Image

Building Computer Vision Projects with OpenCV 4 and C++

By: David Millán Escrivá, Prateek Joshi, Vinícius G. Mendonça, Roy Shilkrot

Overview of this book

OpenCV is one of the best open source libraries available and can help you focus on constructing complete projects on image processing, motion detection, and image segmentation. This Learning Path is your guide to understanding OpenCV concepts and algorithms through real-world examples and activities. Through various projects, you'll also discover how to use complex computer vision and machine learning algorithms and face detection to extract the maximum amount of information from images and videos. In later chapters, you'll learn to enhance your videos and images with optical flow analysis and background subtraction. Sections in the Learning Path will help you get to grips with text segmentation and recognition, in addition to guiding you through the basics of the new and improved deep learning modules. By the end of this Learning Path, you will have mastered commonly used computer vision techniques to build OpenCV projects from scratch. This Learning Path includes content from the following Packt books: •Mastering OpenCV 4 - Third Edition by Roy Shilkrot and David Millán Escrivá •Learn OpenCV 4 By Building Projects - Second Edition by David Millán Escrivá, Vinícius G. Mendonça, and Prateek Joshi
Table of Contents (28 chapters)
Title Page
Copyright and Credits
About Packt
Contributors
Preface
Index

Preface

OpenCV is one of the best open source computer vision libraries available to developers. With OpenCV, developers can create complete projects for image processing, object detection, and motion detection. This learning path is for absolute beginners who wish to learn how to build OpenCV projects from scratch with working code samples. We will begin with the introduction on computer vision and its basic concepts such as filtering, histograms, Object segmentation, and object detection. As you progress through the course you will then dig deeper into image processing exploring various computer vision algorithms and understand how the latest advancement in machine learning and deep learning enhances the process of object detection. You will put this knowledge to practice by building real-world computer vision applications as you progress through the course.  Later you will get acquainted with the API functionality of OpenCV and gain insights into design choices in a complete computer vision project. You'll also go beyond the basics of computer vision to implement solutions for complex image processing projects such as skin color analysis, face landmark and pose estimation, Augmented reality applications, and Number plate recognition. Finally, towards the end of the learning path, you will learn about certain best practices and common pitfalls to avoid while building computer vision applications.

This learning path includes content from the following Packt products:

  • Learn OpenCV 4 by Building Projects, Second Edition by David Millán Escrivá, Prateek Joshi and Vinícius G. Mendonça
  • Mastering OpenCV 4, Third Edition by Roy Shilkrot, David Millán Escrivá

Who this book is for

If you are a software developer with a basic understanding of computer vision and image processing and want to develop interesting computer vision applications with OpenCV, then this course is for you. Prior knowledge of C++ will help you understand the concepts covered in this book.

 

What this book covers

Chapter 1, Getting Started with OpenCV, covers installation steps on various operating systems and provides an introduction to the human visual system, as well as various topics in computer vision.

Chapter 2, Introduction to OpenCV Basics, discusses how to read/write images and videos in OpenCV, and also explains how to build a project using CMake.

Chapter 3, Learning Graphical User Interface and Basic Filtering, covers how to build a graphical user interface and mouse event detector to build interactive applications.

Chapter 4, Delving into Histograms and Filters, explores histograms and filters and also shows how we can cartoonize an image.

Chapter 5, Automated Optical Inspection, Object Segmentation, and Detection, describes various image pre-processing techniques, such as noise removal, thresholding, and contour analysis.

Chapter 6, Learning Object Classification, deals with object recognition and machine learning, and how to use support vector machines to build an object classification system.

Chapter 7, Detecting Face Parts and Overlaying Masks, discusses face detection and Haar Cascades and then explains how these methods can be used to detect various parts of the human face.

Chapter 8, Video Surveillance, Background Modeling, and Morphological Operations, explores background subtraction, video surveillance, and morphological image processing, and describes how they are connected to one another.

Chapter 9, Learning Object Tracking, covers how to track objects in a live video using different techniques, such as color-based and feature-based tracking.

Chapter 10, Developing Segmentation Algorithms for Text Recognition, covers optical character recognition, text segmentation, and provides an introduction to the Tesseract OCR engine.

Chapter 11, Text Recognition with Tesseract, delves deeper into the Tesseract OCR engine to explain how it can be used for text detection, extraction, and recognition.

Chapter 12, Deep Learning with OpenCV, explores how to apply deep learning in OpenCV with two commonly used deep learning architectures: YOLO v3 for object detection, and Single Shot Detector for face detection.

Chapter 13, Cartoonifier and Skin Color Analysis on the RaspberryPi, demonstrates how to write some image processing filters for desktops and for small embedded systems such as Raspberry Pi.

Chapter 14, Explore Structure from Motion with the SfM Module, demonstrates how to use the SfM module to reconstruct a scene to a sparse point cloud, including camera poses, and also obtain a dense point cloud using multi-view stereo.

Chapter 15, Face Landmark and Pose with the Face Module, explains the process of face landmark (also known as facemark) detection using the face module.

Chapter 16, Number Plate Recognition with Deep Convolutional Networks, introduces image segmentation and feature extraction, pattern recognition basics, and two important pattern recognition algorithms, the Support Vector Machine (SVM) and deep neural network (DNN).

Chapter 17, Face Detection and Recognition with the DNN Module, demonstrates different techniques for detecting faces on the images, ranging from more classic algorithms using cascade classifiers with Haar features through to newer techniques employing deep learning.

Chapter 18, Android Camera Calibration and AR Using the ArUco Module, shows how to implement an augmented reality (AR) application in the Android ecosystem, using OpenCV's ArUco module, Android's Camera2 APIs, and the JMonkeyEngine 3D game engine.

Chapter 19, iOS Panoramas with the Stitching Module, shows how to build a panoramic image stitching application on the iPhone using OpenCV's precompiled library for iOS.

Chapter 20, Finding the Best OpenCV Algorithm for the Job, discusses a number of methods to follow when considering options within OpenCV.

Chapter 21, Avoiding Common Pitfalls in OpenCV, reviews the historical development of OpenCV, and the gradual increase in the framework and algorithmic offering, alongside the development of computer vision at large.

 

To get the most out of this book

To start using this course, you will need the following software installed on your local desktop:

  • OpenCV 4.0
  • CMake 3.3.x or newer
  • Tesseract, Leptonica (a dependency of Tesseract)
  • Qt (optional) and OpenGL (optional)
  • Some chapters will require a Python, others an Android, installation

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Building-Computer-Vision-Projects-with-OpenCV4-and-CPlusPlus In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The input() method is used to get an input from the user."

A block of code is set as follows:

Mat bigImg;
resize(smallImg, bigImg, size, 0,0, INTER_LINEAR);
dst.setTo(0);
bigImg.copyTo(dst, mask);

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

sudo apt-get purge -y wolfram-engine

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "If you need something different, click on the DOWNLOADS link in the header for all possible downloads: "

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

 

 

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.