例程讲解20-Frame-Differencing->on_disk_structrual_similarity 需sd卡的结构相似性帧差分
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()
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!")
while(True):
clock.tick()
img = sensor.snapshot()
sim = img.get_similarity("temp/bg.bmp")
change = "- Change -" if sim.min() < MIN_TRIGGER_THRESHOLD else "- No Change -"
print(clock.fps(), change, sim)
星瞳科技OpenMV官方中文文档函数讲解: