mirror of https://github.com/davisking/dlib.git
Added default upsampling amount to detector.run(). Also moved the
new example code into face_detector.py and added some comments.
This commit is contained in:
parent
35b74d1b0f
commit
d1a5815cb9
|
@ -51,11 +51,24 @@ for f in sys.argv[1:]:
|
|||
# faces.
|
||||
dets = detector(img, 1)
|
||||
print("Number of faces detected: {}".format(len(dets)))
|
||||
for k, d in enumerate(dets):
|
||||
for i, d in enumerate(dets):
|
||||
print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format(
|
||||
k, d.left(), d.top(), d.right(), d.bottom()))
|
||||
i, d.left(), d.top(), d.right(), d.bottom()))
|
||||
|
||||
win.clear_overlay()
|
||||
win.set_image(img)
|
||||
win.add_overlay(dets)
|
||||
dlib.hit_enter_to_continue()
|
||||
|
||||
|
||||
# Finally, if you really want to you can ask the detector to tell you the score
|
||||
# for each detection. The score is bigger for more confident detections.
|
||||
# Also, the idx tells you which of the face sub-detectors matched. This can be
|
||||
# used to broadly identify faces in different orientations.
|
||||
if (len(sys.argv[1:]) > 0):
|
||||
img = io.imread(sys.argv[1])
|
||||
dets, scores, idx = detector.run(img, 1)
|
||||
for i, d in enumerate(dets):
|
||||
print("Detection {}, score: {}, face_type:{}".format(
|
||||
d, scores[i], idx[i]))
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
|
||||
from PIL import Image
|
||||
import numpy as np
|
||||
import dlib
|
||||
|
||||
img = np.array(Image.open('../examples/faces/2008_002506.jpg'))
|
||||
detector = dlib.get_frontal_face_detector()
|
||||
|
||||
dets, scores, idx = detector.run(img, 1)
|
||||
|
||||
for i, d in enumerate(dets):
|
||||
print d, scores[i], idx[i]
|
||||
|
|
@ -354,7 +354,7 @@ ensures \n\
|
|||
detector. If you don't know how many times you want to upsample then \n\
|
||||
don't provide a value for upsample_num_times and an appropriate \n\
|
||||
default will be used.")
|
||||
.def("run", run_rect_detector, (arg("image"), arg("upsample_num_times")),
|
||||
.def("run", run_rect_detector, (arg("image"), arg("upsample_num_times")=0),
|
||||
"requires \n\
|
||||
- image is a numpy ndarray containing either an 8bit grayscale or RGB \n\
|
||||
image. \n\
|
||||
|
|
Loading…
Reference in New Issue