From 036c4389040c086645e2f4d1fcd221eabfacb6f7 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Thu, 28 May 2015 19:01:56 +0300 Subject: [PATCH] make facedetect.py work when the nested cascade is not specified --- samples/python2/facedetect.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/samples/python2/facedetect.py b/samples/python2/facedetect.py index 72b8561c3f..8c6b27ab1b 100755 --- a/samples/python2/facedetect.py +++ b/samples/python2/facedetect.py @@ -49,11 +49,12 @@ if __name__ == '__main__': rects = detect(gray, cascade) vis = img.copy() draw_rects(vis, rects, (0, 255, 0)) - for x1, y1, x2, y2 in rects: - roi = gray[y1:y2, x1:x2] - vis_roi = vis[y1:y2, x1:x2] - subrects = detect(roi.copy(), nested) - draw_rects(vis_roi, subrects, (255, 0, 0)) + if not nested.empty(): + for x1, y1, x2, y2 in rects: + roi = gray[y1:y2, x1:x2] + vis_roi = vis[y1:y2, x1:x2] + subrects = detect(roi.copy(), nested) + draw_rects(vis_roi, subrects, (255, 0, 0)) dt = clock() - t draw_str(vis, (20, 20), 'time: %.1f ms' % (dt*1000))