-
Notifications
You must be signed in to change notification settings - Fork 1
/
score.py
55 lines (40 loc) · 1.24 KB
/
score.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
45
46
47
48
49
50
51
52
53
54
55
import argparse
from utils import (
convert_cv2matplot,
detect_faces,
FaceParams,
get_abspath,
is_url,
mark_faces,
option_parser,
plot_side_by_side_comparison,
read_cv_image_from,
)
# ----------------------------------------------------------------------
# Parse command line arguments
# ----------------------------------------------------------------------
parser = argparse.ArgumentParser(
prog='score',
parents=[option_parser],
description='Detect faces in an image.'
)
parser.add_argument(
'image',
type=str,
help='image path or URL'
)
args = parser.parse_args()
# Wrap face detection parameters.
face_params = FaceParams(
args.scaleFactor,
args.minNeighbors,
args.minSize)
# ----------------------------------------------------------------------
# Face detection
# ----------------------------------------------------------------------
image = read_cv_image_from(args.image if is_url(args.image) else get_abspath(args.image))
faces = detect_faces(image, face_params=face_params)
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")