Last active
February 20, 2017 18:22
-
-
Save abhiksark/4b0a6e06e0b7553aa09d7440c0fdc8e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Mon Feb 20 14:02:08 2017 | |
@author: Abhik | |
""" | |
import os | |
import cv2 | |
import numpy as np | |
from PIL import Image | |
cascadePath = "haarcascade_frontalface_default.xml" | |
faceCascade = cv2.CascadeClassifier(cascadePath) | |
path='./' | |
image_paths = [os.path.join(path, f) for f in os.listdir('./')] | |
for image_path in image_paths: | |
predict_image_pil = Image.open(image_path).convert('L') | |
predict_image = np.array(predict_image_pil, 'uint8') | |
faces = faceCascade.detectMultiScale( | |
predict_image, | |
scaleFactor = 1.1, | |
flags = cv2.CASCADE_SCALE_IMAGE | |
) | |
for (x, y, w, h) in faces: | |
#nbr_predicted, conf = recognizer.predict(predict_image[y: y + h, x: x + w]) | |
cv2.rectangle(predict_image,(x,y),(x+w,y+h),(255,0,0),2) | |
cv2.imshow('img',predict_image) | |
cv2.waitKey(100) | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment