-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.py
44 lines (30 loc) · 1.08 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import glob
import os
from utils import (
convert_cv2matplot,
detect_faces,
mark_faces,
plot_side_by_side_comparison,
read_cv_image_from,
)
# ----------------------------------------------------------------------
# Setup
# ----------------------------------------------------------------------
IMG_PATH = 'images'
cwd = os.getcwd()
print("Demonstrate face detection using images found in\n{}\n".format(
os.path.join(cwd, IMG_PATH)
))
print("Please close each image (Ctrl-w) to proceed through the demonstration.\n")
imagePaths = glob.glob(os.path.join(IMG_PATH, "*"))
imagePaths.sort()
# ----------------------------------------------------------------------
# Face detection
# ----------------------------------------------------------------------
for imagePath in imagePaths:
image = read_cv_image_from(imagePath)
faces = detect_faces(image)
print("Found {0} faces!".format(len(faces)))
result = mark_faces(image, faces)
image, result = convert_cv2matplot(image, result)
plot_side_by_side_comparison(image, result, rightlabel="Detected Faces")