February 2020
Intermediate to advanced
372 pages
9h 26m
English
The first and most basic way to perform face detection is to load an image and detect faces in it. To make the result visually meaningful, we will draw rectangles around faces in the original image. Remembering that the face detector is designed for upright, frontal faces, we will use an image of a row of people, specifically woodcutters, standing shoulder-to-shoulder and facing the viewer.
Having copied the Haar cascade XML files into our cascades folder, let's go ahead and create the following basic script to perform face detection:
import cv2face_cascade = cv2.CascadeClassifier( './cascades/haarcascade_frontalface_default.xml')img = cv2.imread('../images/woodcutters.jpg')gray = cv2.cvtColor(img, ...