Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning OpenCV 3 Computer Vision with Python (Update)

You're reading from   Learning OpenCV 3 Computer Vision with Python (Update) Unleash the power of computer vision with Python using OpenCV

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781785283840
Length 266 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Table of Contents (11) Chapters Close

Preface 1. Setting Up OpenCV FREE CHAPTER 2. Handling Files, Cameras, and GUIs 3. Processing Images with OpenCV 3 4. Depth Estimation and Segmentation 5. Detecting and Recognizing Faces 6. Retrieving Images and Searching Using Image Descriptors 7. Detecting and Recognizing Objects 8. Tracking Objects 9. Neural Networks with OpenCV – an Introduction Index

Creating a mask from a disparity map

For the purposes of Cameo, we are interested in disparity maps and valid depth masks. They can help us refine our estimates of facial regions.

Using the FaceTracker function and a normal color image, we can obtain rectangular estimates of facial regions. By analyzing such a rectangular region in the corresponding disparity map, we can tell that some pixels within the rectangle are outliers—too near or too far to really be a part of the face. We can refine the facial region to exclude these outliers. However, we should only apply this test where the data is valid, as indicated by the valid depth mask.

Let's write a function to generate a mask whose values are 0 for the rejected regions of the facial rectangle and 1 for the accepted regions. This function should take a disparity map, valid depth mask, and a rectangle as arguments. We can implement it in depth.py as follows:

def createMedianMask(disparityMap, validDepthMask, rect = None):
    ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £16.99/month. Cancel anytime