Update face detection example

This commit is contained in:
iabdalkader 2016-02-17 22:09:02 +02:00
parent 61f98e6c21
commit 6b5cdce4aa

View File

@ -6,12 +6,12 @@ sensor.reset()
# Sensor settings
sensor.set_contrast(1)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.QCIF)
sensor.set_framesize(sensor.HQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
# Load Haar Cascade
# By default this will use all stages, lower satges is faster but less accurate.
face_cascade = image.HaarCascade("frontalface", stages=16)
face_cascade = image.HaarCascade("frontalface", stages=25)
print(face_cascade)
# FPS clock
@ -26,16 +26,12 @@ while (True):
# Find objects.
# Note: Lower scale factor scales-down the image more and detects smaller objects.
# Higher threshold results in a higher detection rate, with more false positives.
objects = img.find_features(face_cascade, threshold=0.65, scale=1.65)
objects = img.find_features(face_cascade, threshold=0.5, scale=1.5)
# Draw objects
for r in objects:
img.draw_rectangle(r)
if (len(objects)):
# Add a small delay to see the drawing on the FB
time.sleep(100)
# Print FPS.
# Note: Actual FPS is higher, streaming the FB makes it slower.
print(clock.fps())