From 1ec5a9455401768f33717e451a53f39629912a0e Mon Sep 17 00:00:00 2001 From: Davis King Date: Sat, 10 Feb 2018 16:58:02 -0500 Subject: [PATCH] Added comments about how to run multiple detectors together efficiently. --- python_examples/train_object_detector.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/python_examples/train_object_detector.py b/python_examples/train_object_detector.py index a442fda2b..aef3fe16d 100755 --- a/python_examples/train_object_detector.py +++ b/python_examples/train_object_detector.py @@ -131,6 +131,20 @@ for f in glob.glob(os.path.join(faces_folder, "*.jpg")): +# Next, suppose you have trained multiple detectors and you want to run them +# efficiently as a group. You can do this as follows: +detector1 = dlib.fhog_object_detector("detector.svm") +# In this example we load detector.svm again since it's the only one we have on +# hand. But in general it would be a different detector. +detector2 = dlib.fhog_object_detector("detector.svm") +# make a list of all the detectors you wan to run. Here we have 2, but you +# could have any number. +detectors = [detector1, detector2] +image = io.imread(faces_folder + '/2008_002506.jpg'); +[boxes, confidences, detector_idxs] = dlib.fhog_object_detector.run_multiple(detectors, image, upsample_num_times=1, adjust_threshold=0.0) +for i in range(len(boxes)): + print("detector {} found box {} with confidence {}.".format(detector_idxs[i], boxes[i], confidences[i])) +