Skip to Content
OpenCV 4 with Python Blueprints - Second Edition
book

OpenCV 4 with Python Blueprints - Second Edition

by Dr. Menua Gevorgyan, Michael Beyeler (USD), Arsen Mamikonyan, Michael Beyeler
March 2020
Intermediate to advanced
366 pages
9h 8m
English
Packt Publishing
Content preview from OpenCV 4 with Python Blueprints - Second Edition

Detecting faces in grayscale images

Now, we will put what we learned in the previous section into a method that will take an image and return the biggest face in the image. We are returning the biggest face to simplify things since we know that, in our application, there is going to be a single user sitting in front of the webcam. As a challenge, you could try to expand this to work with more than one face!

We call the method to detect the biggest face (detect_face). Let's go through it step by step:

  1. As in the last section, first, we convert the argument RGB image to grayscale and scale it by scale_factor by running the following code:
    def detect_face(self, rgb_img, *, outline=True): frameCasc = cv2.cvtColor(cv2.resize(rgb_img, (0, 0), ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

OpenCV with Python Blueprints

OpenCV with Python Blueprints

Michael Beyeler, Michael Beyeler (USD)
OpenCV 3 Computer Vision with Python Cookbook

OpenCV 3 Computer Vision with Python Cookbook

Aleksei Spizhevoi, Aleksandr Rybnikov
Mastering OpenCV 4 with Python

Mastering OpenCV 4 with Python

Alberto Fernández Villán

Publisher Resources

ISBN: 9781789801811Supplemental Content