ルーチン説明 06-Video-Recording->gif_on_face_detection 録画顔認識アニメーション
import sensor
import image
import time
import gif
import machine
import random
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time=2000)
led = machine.LED("LED_RED")
face_cascade = image.HaarCascade("frontalface", stages=25)
while True:
print("About to start detecting faces...")
sensor.skip_frames(time=2000)
print("Now detecting faces!")
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)
led.on()
g = gif.Gif("example-%d.gif" % random.getrandbits(32), loop=True)
clock = time.clock()
for i in range(100):
clock.tick()
g.add_frame(sensor.snapshot(), delay=int(clock.avg() / 10))
print(clock.fps())
g.close()
led.off()
print("Restarting...")
Singtown Technology OpenMV
公式中国語ドキュメント機能説明:
Singtown Technology OpenMV
公式中国語ドキュメント機能説明: