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

Estimating face direction from landmarks


Having obtained the facial landmarks, we can attempt to find the direction of the face. The 2D face landmark points essentially conform to the shape of the head. So, given a 3D model of a generic human head, we can find approximate corresponding 3D points for a number of facial landmarks, as shown in the following photo:

Estimated pose calculation

From these 2D–3D correspondences, we can calculate 3D pose (rotation and translation) of the head, with respect to the camera, by way of the Point-n-Perspective (PnP) algorithm. The details of the algorithm and object pose detection are beyond the scope of this chapter; however, we can quickly rationalize why just a handful of 2D–3D point correspondences are suffice to achieve this. The camera that took the preceding picture has a rigid transformation, meaning it has moved a certain distance from the object, as well as rotated somewhat, with respect to it. In very broad terms, we can then write the relationship...