实验结果:
程序代码:
import sensor, time, image, pyb
led = pyb.LED(3)
sensor.reset()
sensor.set_contrast(1)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.HQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
face_cascade = image.HaarCascade("frontalface", stages=25)
print(face_cascade)
clock = time.clock()
while (True):
clock.tick()
img = sensor.snapshot()
objects = img.find_features(face_cascade, threshold=0.75, scale_factor=1.25)
for r in objects:
img.draw_rectangle(r)
led.on() #亮灯
time.sleep(150) #延时150ms
led.off() #暗灯
time.sleep(100)
print(clock.fps())