Skip to content

Instantly share code, notes, and snippets.

@LimaGuilherme
Last active July 1, 2020 14:55
Show Gist options
  • Save LimaGuilherme/a2f18434ee062e95a906fc1e370fb520 to your computer and use it in GitHub Desktop.
Save LimaGuilherme/a2f18434ee062e95a906fc1e370fb520 to your computer and use it in GitHub Desktop.
import cv2
group_of_people_image = cv2.imread('images/image7.jpg')
frontal_face_classifier = cv2.CascadeClassifier('classifier/haarcascade_frontalface_default.xml')
image_in_gray_scale = cv2.cvtColor(group_of_people_image, cv2.COLOR_BGR2GRAY)
faces = frontal_face_classifier.detectMultiScale(image=image_in_gray_scale, scaleFactor=1.3, minNeighbors=6)
for (x_axis, y_axis, weight, height) in faces:
cv2.rectangle(group_of_people_image, (x_axis, y_axis), (x_axis + weight, y_axis + height), (255, 0, 0), 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment