OpenMV人脸识别

来源:互联网 发布:空手道数据集 编辑:程序博客网 时间:2024/06/09 20:56

实验结果:


程序代码:

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())