例程讲解20-Frame-Differencing->on_disk_advanced_frame_differencing 需sd卡的高级帧差分
import sensor, image, pyb, os, time
TRIGGER_THRESHOLD = 5
BG_UPDATE_FRAMES = 50
BG_UPDATE_BLEND = 128
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_whitebal(False)
clock = time.clock()
if not "temp" in os.listdir(): os.mkdir("temp")
print("About to save background image...")
sensor.skip_frames(time = 2000)
sensor.snapshot().save("temp/bg.bmp")
print("Saved background image - Now frame differencing!")
triggered = False
frame_count = 0
while(True):
clock.tick()
img = sensor.snapshot()
frame_count += 1
if (frame_count > BG_UPDATE_FRAMES):
frame_count = 0
img.blend("temp/bg.bmp", alpha=(256-BG_UPDATE_BLEND))
img.save("temp/bg.bmp")
img.difference("temp/bg.bmp")
hist = img.get_histogram()
diff = hist.get_percentile(0.99).l_value() - hist.get_percentile(0.90).l_value()
triggered = diff > TRIGGER_THRESHOLD
print(clock.fps(), triggered)
星瞳科技OpenMV官方中文文档函数讲解:

星瞳科技OpenMV官方中文文档函数讲解:

星瞳科技OpenMV官方中文文档函数讲解:

星瞳科技OpenMV官方中文文档函数讲解:

星瞳科技OpenMV官方中文文档函数讲解:
