例程讲解20-Frame-Differencing->in_memory_structrual_similarity 结构相似性帧差分
import sensor, image, pyb, os, time
MIN_TRIGGER_THRESHOLD = -0.4
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()
extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.RGB565)
print("About to save background image...")
sensor.skip_frames(time = 2000)
extra_fb.replace(sensor.snapshot())
print("Saved background image!")
while(True):
clock.tick()
img = sensor.snapshot()
sim = img.get_similarity(extra_fb)
change = "- Change -" if sim.min() < MIN_TRIGGER_THRESHOLD else "- No Change -"
print(clock.fps(), change, sim)
星瞳科技OpenMV官方中文文档函数讲解: