例程讲解06-Video-Recording->gif_on_movement录制移动物体动图
import sensor
import time
import gif
import os
import machine
import random
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time=2000)
sensor.set_auto_whitebal(False)
led = machine.LED("LED_RED")
if not "temp" in os.listdir():
os.mkdir("temp")
while True:
print("About to save background image...")
sensor.skip_frames(time=2000)
sensor.snapshot().save("temp/bg.bmp")
print("Saved background image - Now detecting motion!")
diff = 10
while diff:
img = sensor.snapshot()
img.difference("temp/bg.bmp")
stats = img.statistics()
if stats[5] > 20:
diff -= 1
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...")
星瞳科技OpenMV官方中文文档函数讲解:
星瞳科技OpenMV官方中文文档函数讲解:
星瞳科技OpenMV官方中文文档函数讲解: