face-detector: opencv based haarcascade
diff --git a/apps/face-detection/haar.py b/apps/face-detection/haar.py
new file mode 100644
index 0000000..f4966ea
--- /dev/null
+++ b/apps/face-detection/haar.py
@@ -0,0 +1,11 @@
+import cv2
+
+def detect_faces(img_file):
+ face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
+ img = cv2.imread(img_file)
+ gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+ faces = face_cascade.detectMultiScale(gray, 1.1, 4)
+ ret = []
+ for (x, y, w, h) in faces:
+ ret.append((x, y, x + w, y + h))
+ return ret