Book description
Recipe-based approach to tackle the most common problems in Computer Vision by leveraging the functionality of OpenCV using Python APIs
About This Book
- Build computer vision applications with OpenCV functionality via Python API
- Get to grips with image processing, multiple view geometry, and machine learning
- Learn to use deep learning models for image classification, object detection, and face recognition
Who This Book Is For
This book is for developers who have a basic knowledge of Python. If you are aware of the basics of OpenCV and are ready to build computer vision systems that are smarter, faster, more complex, and more practical than the competition, then this book is for you.
What You Will Learn
- Get familiar with low-level image processing methods
- See the common linear algebra tools needed in computer vision
- Work with different camera models and epipolar geometry
- Find out how to detect interesting points in images and compare them
- Binarize images and mask out regions of interest
- Detect objects and track them in videos
In Detail
OpenCV 3 is a native cross-platform library for computer vision, machine learning, and image processing. OpenCV's convenient high-level APIs hide very powerful internals designed for computational efficiency that can take advantage of multicore and GPU processing. This book will help you tackle increasingly challenging computer vision problems by providing a number of recipes that you can use to improve your applications.
In this book, you will learn how to process an image by manipulating pixels and analyze an image using histograms. Then, we'll show you how to apply image filters to enhance image content and exploit the image geometry in order to relay different views of a pictured scene. We'll explore techniques to achieve camera calibration and perform a multiple-view analysis.
Later, you'll work on reconstructing a 3D scene from images, converting low-level pixel information to high-level concepts for applications such as object detection and recognition. You'll also discover how to process video from files or cameras and how to detect and track moving objects. Finally, you'll get acquainted with recent approaches in deep learning and neural networks.
By the end of the book, you'll be able to apply your skills in OpenCV to create computer vision applications in various domains.
Style and approach
This book helps you learn the core concepts of OpenCV faster by taking a recipe-based approach where you can try out different code snippets to understand a concept.
Table of contents
- Title Page
- Copyright and Credits
- Packt Upsell
- Contributors
- Preface
-
I/O and GUI
- Introduction
- Reading images from files
- Simple image transformations—resizing and flipping
- Saving images using lossy and lossless compression
- Showing images in an OpenCV window
- Working with UI elements, such as buttons and trackbars, in an OpenCV window
- Drawing 2D primitives—markers, lines, ellipses, rectangles, and text
- Handling user input from a keyboard
- Making your app interactive through handling user input from a mouse
- Capturing and showing frames from a camera
- Playing frame stream from video
- Obtaining a frame stream properties
- Writing a frame stream into video
- Jumping between frames in video files
-
Matrices, Colors, and Filters
- Introduction
- Manipulating matrices-creating, filling, accessing elements, and ROIs
- Converting between different data types and scaling values
- Non-image data persistence using NumPy
- Manipulating image channels
- Converting images from one color space to another
- Gamma correction and per-element math
- Mean/variance image normalization
- Computing image histograms
- Equalizing image histograms
- Removing noise using Gaussian, median, and bilateral filters
- Computing gradients using Sobel operator
- Creating and applying your own filter
- Processing images with real-valued Gabor filters
- Going from the spatial domain to the frequency domain (and back) using the discrete Fourier transform
- Manipulating image frequencies for image filtration
- Processing images with different thresholds
- Morphological operators
- Image masks and binary operations
-
Contours and Segmentation
- Introduction
- Binarization of grayscale images using the Otsu algorithm
- Finding external and internal contours in a binary image
- Extracting connected components from a binary image
- Fitting lines and circles into two-dimensional point sets
- Calculating image moments
- Working with curves - approximation, length, and area
- Checking whether a point is within a contour
- Computing distance maps
- Image segmentation using the k-means algorithm
- Image segmentation using segment seeds - the watershed algorithm
-
Object Detection and Machine Learning
- Introduction
- Obtaining an object mask using the GrabCut algorithm
- Finding edges using the Canny algorithm
- Detecting lines and circles using the Hough transform
- Finding objects via template matching
- The medial flow tracker
- Tracking objects using different algorithms via the tracking API
- Computing the dense optical flow between two frames
- Detecting chessboard and circle grid patterns
- A simple pedestrian detector using the SVM model
- Optical character recognition using different machine learning models
- Detecting faces using Haar/LBP cascades
- Detecting AruCo patterns for AR applications
- Detecting text in natural scenes
- QR code detector
-
Deep Learning
- Introduction
- Representing images as tensors/blobs
- Loading deep learning models from Caffe, Torch, and TensorFlow formats
- Getting input and output tensors' shapes for all layers
- Preprocessing images and inference in convolutional networks
- Measuring inference time and contributions to it from each layer
- Classifying images with GoogleNet/Inception and ResNet models
- Detecting objects with the Single Shot Detection (SSD) model
- Segmenting a scene using the Fully Convolutional Network (FCN) model
- Face detection using Single Shot Detection (SSD) and the ResNet model
- Age and gender prediction
- Linear Algebra
-
Detectors and Descriptors
- Introduction
- Finding corners in an image - Harris and FAST
- Selecting good corners in an image for tracking
- Drawing keypoints, descriptors, and matches
- Detecting scale invariant keypoints
- Computing descriptors for image keypoints - SURF, BRIEF, ORB
- Matching techniques for finding correspondences between descriptors
- Finding reliable matches - cross-check and ratio test
- Model-based filtering of matches - RANSAC
- BoW model for constructing global image descriptors
-
Image and Video Processing
- Introduction
- Warping an image using affine and perspective transformations
- Remapping an image using arbitrary transformation
- Tracking keypoints between frames using the Lucas-Kanade algorithm
- Background subtraction
- Stitching many images into panorama
- Denoising a photo using non-local means algorithms
- Constructing an HDR image
- Removing defects from a photo with image inpainting
-
Multiple View Geometry
- Introduction
- Pinhole camera model calibration
- Fisheye camera model calibration
- Stereo rig calibration - estimation of extrinsics
- Distorting and undistorting points
- Removing lens distortion effects from an image
- Restoring a 3D point from two observations through triangulation
- Finding a relative camera-object pose through the PnP algorithm
- Aligning two views through stereo rectification
- Epipolar geometry - computing fundamental and essential matrices
- Essential matrix decomposition into rotation and translation
- Estimating disparity maps for stereo images
- Special case 2-view geometry - estimating homography transformation
- Planar scene - decomposing homography into rotation and translation
- Rotational camera case - estimating camera rotation from homography
- Other Books You May Enjoy
Product information
- Title: OpenCV 3 Computer Vision with Python Cookbook
- Author(s):
- Release date: March 2018
- Publisher(s): Packt Publishing
- ISBN: 9781788474443
You might also like
book
OpenCV with Python By Example
Build real-world computer vision applications and develop cool demos using OpenCV for Python About This Book …
book
OpenCV 4 Computer Vision Application Programming Cookbook - Fourth Edition
Discover interesting recipes to help you understand the concepts of object detection, image processing, and facial …
book
OpenCV 4 with Python Blueprints - Second Edition
Get to grips with traditional computer vision algorithms and deep learning approaches, and build real-world applications …
book
Computer Vision Projects with OpenCV and Python 3
Gain a working knowledge of advanced machine learning and explore Python's powerful tools for extracting data …