Learning OpenCV 4 Computer Vision with Python 3: Get to grips with tools, techniques, and algorithms for computer vision and machine learning
Book information
Description
Updated for OpenCV 4 and Python 3, this book covers the latest on depth cameras, 3D tracking, augmented reality, and deep neural networks, helping you solve real-world computer vision problems with practical code Key Features • Build powerful computer vision applications in concise code with OpenCV 4 and Python 3 • Learn the fundamental concepts of image processing, object classification, and 2D and 3D tracking • Train, use, and understand machine learning models such as Support Vector Machines (SVMs) and neural networks Book Description Computer vision is a rapidly evolving science, encompassing diverse applications and techniques. This book will not only help those who are getting started with computer vision but also experts in the domain. You'll be able to put theory into practice by building apps with OpenCV 4 and Python 3. You'll start by understanding OpenCV 4 and how to set it up with Python 3 on various platforms. Next, you'll learn how to perform basic operations such as reading, writing, manipulating, and displaying still images, videos, and camera feeds. From taking you through image processing, video analysis, and depth estimation and segmentation, to helping you gain practice by building a GUI app, this book ensures you'll have opportunities for hands-on activities. Next, you'll tackle two popular challenges: face detection and face recognition. You'll also learn about object classification and machine learning concepts, which will enable you to create and use object detectors and classifiers, and even track objects in movies or video camera feed. Later, you'll develop your skills in 3D tracking and augmented reality. Finally, you'll cover ANNs and DNNs, learning how to develop apps for recognizing handwritten digits and classifying a person's gender and age. By the end of this book, you'll have the skills you need to execute real-world computer vision projects. What you will learn • Install and familiarize yourself with OpenCV 4's Python 3 bindings • Understand image processing and video analysis basics • Use a depth camera to distinguish foreground and background regions • Detect and identify objects, and track their motion in videos • Train and use your own models to match images and classify objects • Detect and recognize faces, and classify their gender and age • Build an augmented reality application to track an image in 3D • Work with machine learning models, including SVMs, artificial neural networks (ANNs), and deep neural networks (DNNs) Who this book is for If you are interested in learning computer vision, machine learning, and OpenCV in the context of practical real-world applications, then this book is for you. This OpenCV book will also be useful for anyone getting started with computer vision as well as experts who want to stay up-to-date with OpenCV 4 and Python 3. Although no prior knowledge of image processing, computer vision or machine learning is required, familiarity with basic Python programming is a must. Cover Title Page Copyright and Credits Dedication About Packt Contributors Table of Contents Preface Chapter 1: Setting Up OpenCV Technical requirements What's new in OpenCV 4 Choosing and using the right setup tools Installation on Windows Using a ready-made OpenCV package Building OpenCV from source Installation on macOS Using Homebrew with ready-made packages Using Homebrew with your own custom packages Installation on Debian, Ubuntu, Linux Mint, and similar systems Using a ready-made OpenCV package Building OpenCV from source Installation on other Unix-like systems Running samples Finding documentation, help, and updates Summary Chapter 2: Handling Files, Cameras, and GUIs Technical requirements Basic I/O scripts Reading/writing an image file Converting between an image and raw bytes Accessing image data with numpy.array Reading/writing a video file Capturing camera frames Displaying an image in a window Displaying camera frames in a window Project Cameo (face tracking and image manipulation) Cameo – an object-oriented design Abstracting a video stream with managers.CaptureManager Abstracting a window and keyboard with managers.WindowManager Applying everything with cameo.Cameo Summary Chapter 3: Processing Images with OpenCV Technical requirements Converting images between different color models Light is not paint Exploring the Fourier transform HPFs and LPFs Creating modules Edge detection Custom kernels – getting convoluted Modifying the application Edge detection with Canny Contour detection Bounding box, minimum area rectangle, and minimum enclosing circle Convex contours and the Douglas-Peucker algorithm Detecting lines, circles, and other shapes Detecting lines Detecting circles Detecting other shapes Summary Chapter 4: Depth Estimation and Segmentation Technical requirements Creating modules Capturing frames from a depth camera Converting 10-bit images to 8-bit Creating a mask from a disparity map Modifying the application Depth estimation with a normal camera Foreground detection with the GrabCut algorithm Image segmentation with the Watershed algorithm Summary Chapter 5: Detecting and Recognizing Faces Technical requirements Conceptualizing Haar cascades Getting Haar cascade data Using OpenCV to perform face detection Performing face detection on a still image Performing face detection on a video Performing face recognition Generating the data for face recognition Recognizing faces Loading the training data for face recognition Performing face recognition with Eigenfaces Performing face recognition with Fisherfaces Performing face recognition with LBPH Discarding results based on the confidence score Swapping faces in the infrared Modifying the application's loop Masking a copy operation Summary Chapter 6: Retrieving Images and Searching Using Image Descriptors Technical requirements Understanding types of feature detection and matching Defining features Detecting Harris corners Detecting DoG features and extracting SIFT descriptors Anatomy of a keypoint Detecting Fast Hessian features and extracting SURF descriptors Using ORB with FAST features and BRIEF descriptors FAST BRIEF Brute-force matching Matching a logo in two images Filtering matches using K-Nearest Neighbors and the ratio test Matching with FLANN Performing homography with FLANN-based matches A sample application – tattoo forensics Saving image descriptors to file Scanning for matches Summary Chapter 7: Building Custom Object Detectors Technical requirements Understanding HOG descriptors Visualizing HOG Using HOG to describe regions of an image Understanding NMS Understanding SVMs Detecting people with HOG descriptors Creating and training an object detector Understanding BoW Applying BoW to computer vision k-means clustering Detecting cars Combining an SVM with a sliding window Detecting a car in a scene Saving and loading a trained SVM Summary Chapter 8: Tracking Objects Technical requirements Detecting moving objects with background subtraction Implementing a basic background subtractor Using a MOG background subtractor Using a KNN background subtractor Using GMG and other background subtractors Tracking colorful objects using MeanShift and CamShift Planning our MeanShift sample Calculating and back-projecting color histograms Understanding the parameters of cv2.calcHist Understanding the parameters of cv2.calcBackProject Implementing the MeanShift example Using CamShift Finding trends in motion using the Kalman filter Understanding the predict and update phases Tracking a mouse cursor Tracking pedestrians Planning the flow of the application Comparing the object-oriented and functional paradigms Implementing the Pedestrian class Implementing the main function Considering the next steps Summary Chapter 9: Camera Models and Augmented Reality Technical requirements Understanding 3D image tracking and augmented reality Understanding camera and lens parameters Understanding cv2.solvePnPRansac Implementing the demo application Importing modules Performing grayscale conversion Performing 2D-to-3D spatial conversions Implementing the application class Initializing the tracker Implementing the main loop Tracking the image in 3D Initializing and applying the Kalman filter Drawing the tracking results and masking the tracked object Running and testing the application Improving the 3D tracking algorithm Summary Chapter 10: Introduction to Neural Networks with OpenCV Technical requirements Understanding ANNs Understanding neurons and perceptrons Understanding the layers of a neural network Choosing the size of the input layer Choosing the size of the output layer Choosing the size of the hidden layer Training a basic ANN in OpenCV Training an ANN classifier in multiple epochs Recognizing handwritten digits with an ANN Understanding the MNIST database of handwritten digits Choosing training parameters for the MNIST database Implementing a module to train the ANN Implementing a minimal test module Implementing the main module Trying to improve the ANN's training Finding other potential applications Using DNNs from other frameworks in OpenCV Detecting and classifying objects with third-party DNNs Detecting and classifying faces with third-party DNNs Summary Appendix A: Bending Color Space with the Curves Filter Other Book You May Enjoy Index
Similar books
Learning Opencv 3 Computer Vision with Python
2015 · PDF
Learning OpenCV 4 Computer Vision with Python
2020 · PDF
Learning OpenCV 5 Computer Vision with Python: Tackle computer vision and machine learning with the newest tools, techniques and algorithms, 4th Edition
2025 · EPUB
Learning OpenCV 3 Computer Vision with Python
2015 · EPUB
Learning OpenCV 3 Computer Vision with Python
2015 · EPUB
Data Analytics in the Aws Cloud: Building a Data Platform for Bi and Predictive Analytics on Aws
2023 · MOBI
Data Analytics in the AWS Cloud: Building a Data Platform for BI and Predictive Analytics on AWS
2023 · RAR
Data Analytics in the AWS Cloud: Building a Data Platform for BI and Predictive Analytics on AWS
2023 · EPUB