Skip to content

Instantly share code, notes, and snippets.

@MiguelAngelHFlores
Created March 9, 2019 19:52
Show Gist options
  • Save MiguelAngelHFlores/15eb7e0bae432678e1732ba537028cd0 to your computer and use it in GitHub Desktop.
Save MiguelAngelHFlores/15eb7e0bae432678e1732ba537028cd0 to your computer and use it in GitHub Desktop.
import cv2
import sys
imagePath = sys.argv[1]
cascPath = "haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(cascPath)
image = cv2.imread('iron_maiden.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
faces = faceCascade.detectMultiScale(
gray,
scaleFactor=1.1,
minNeighbors=5,
minSize=(30, 30),
flags = cv2.CASCADE_SCALE_IMAGE
)
print("Se encontraron {0} rostros".format(len(faces)))
for (x, y, w, h) in faces:
cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
cv2.imshow("Rostros encontrados", image)
cv2.waitKey(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment