March 2020
Intermediate to advanced
366 pages
9h 8m
English
All relevant face detection code for this chapter can be found as part of the FaceDetector class in the detectors module. Upon instantiation, this class loads two different cascade classifiers that are needed for preprocessing—namely, a face_cascade classifier and an eye_cascade classifier, as follows:
import cv2 import numpy as np class FaceDetector: def __init__(self, *, face_cascade='params/haarcascade_frontalface_default.xml', eye_cascade='params/haarcascade_lefteye_2splits.xml', scale_factor=4):
Because our preprocessing requires a valid face cascade, we make sure that the file can be loaded. If not, we throw a ValueError exception, so the program will terminate and notify the user what went wrong, ...