import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
face_cascade = cv.CascadeClassifier('resources/haarcascade_frontalface_default.xml')
img = cv.imread('resources/person-of-the-year-poll-2019.jpg')
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
print("faces found:", len(faces))
for (x,y,w,h) in faces:
cv.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
plt.figure(figsize=(10,10))
plt.imshow(img)
faces found: 13
<matplotlib.image.AxesImage at 0x7f02e42bd6d8>