例程讲解06-Video-Recording->gif_on_face_detection录制人脸识别动图
import sensor, image, time, gif, pyb
RED_LED_PIN = 1
BLUE_LED_PIN = 3
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
face_cascade = image.HaarCascade("frontalface", stages=25)
while(True):
pyb.LED(RED_LED_PIN).on()
print("About to start detecting faces...")
sensor.skip_frames(time = 2000)
pyb.LED(RED_LED_PIN).off()
print("Now detecting faces!")
pyb.LED(BLUE_LED_PIN).on()
diff = 10
while(diff):
img = sensor.snapshot()
faces = img.find_features(face_cascade, threshold=0.5, scale_factor=1.5)
if faces:
diff -= 1
for r in faces:
img.draw_rectangle(r)
g = gif.Gif("example-%d.gif" % pyb.rng(), loop=True)
clock = time.clock()
print("You're on camera!")
for i in range(100):
clock.tick()
g.add_frame(sensor.snapshot(), delay=int(clock.avg()/10))
print(clock.fps())
g.close()
pyb.LED(BLUE_LED_PIN).off()
print("Restarting...")
星瞳科技OpenMV官方中文文档函数讲解:
星瞳科技OpenMV官方中文文档函数讲解: