Created
November 17, 2019 14:42
-
-
Save boochow/276d3dd22cfb1a19146d9ca433be8af3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sensor, lcd, image | |
sensor.reset() | |
sensor.set_framesize(sensor.QVGA) | |
sensor.set_pixformat(sensor.RGB565) | |
sensor.set_hmirror(False) | |
lcd.init(freq=15000000) | |
face_cascade = image.HaarCascade("frontalface", stages=25) | |
while (True): | |
img = sensor.snapshot() | |
img.lens_corr(1.06,zoom=1.0) | |
img.draw_string(0, 0, "Looking for a face...") | |
g = img.to_grayscale(copy=True) | |
objects = g.find_features(face_cascade, threshold=0.5, scale=1.25) | |
if objects: | |
face = (objects[0][0]-31, objects[0][1]-31,objects[0][2]+31*2, objects[0][3]+31*2) | |
kpts1 = g.find_keypoints(threshold=10, scale_factor=1.1, max_keypoints=100, roi=face) | |
img.draw_rectangle(objects[0]) | |
lcd.display(img) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment