in_memory_structural_similarity.py
import csi
import image
import time
MIN_TRIGGER_THRESHOLD = -0.4
csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.QVGA)
csi0.snapshot(time=2000)
csi0.auto_whitebal(False)
clock = time.clock()
extra_fb = image.Image(csi0.width(), csi0.height(), csi0.pixformat())
print("About to save background image...")
csi0.snapshot(time=2000)
extra_fb.draw_image(csi0.snapshot())
print("Saved background image!")
while True:
clock.tick()
img = csi0.snapshot()
sim = img.get_similarity(extra_fb)
change = "- Change -" if sim.min < MIN_TRIGGER_THRESHOLD else "- No Change -"
print(clock.fps(), change, sim)