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