import sensor, image, time
# Initialize the camera sensor
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time=2000)
# Load the Haar Cascade for face detection
face_cascade = image.HaarCascade("frontalface", stages=25)
print("Loaded Haar cascade")
while(True):
img = sensor.snapshot()
# Detect faces in the image
faces = img.find_features(face_cascade, threshold=0.75, scale_factor=1.25)
# Draw rectangles around detected faces
for x, y, w, h in faces:
img.draw_rectangle(x, y, w, h)