
img = cv2.imread('faces.jpeg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.1, 4)
for (x, y, w, h) in faces:
cv2.rectangle(img, (x, y),(x+w, y+h),(255, 0, 0),2)
cv2.imshow('Faces', img)
cv2.waitKey(0)
Load the Haar cascades classifier.
Convert the image to grayscale, as Haar cascades do not work
on color images
Detect faces according to the detectMultiScale function, which
takes the image, the relative size of the included faces, and
a parameter specifying how sensitive the algorithm should be to
“face-like” structures.
Draw a rectangle around each detected face in the image.
If your pictur ...