热成像叠加演示
import csi
import image
import time
import fir
import display
drawing_hint = image.BICUBIC | image.CENTER | image.SCALE_ASPECT_KEEP
ALT_OVERLAY = False
csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize((128, 160))
csi0.snapshot(time=2000)
fir.init()
lcd = display.SPIDisplay()
extra_fb = image.Image(csi0.width(), csi0.height(), csi0.pixformat())
clock = time.clock()
while True:
clock.tick()
img = csi0.snapshot()
try:
ta, ir, to_min, to_max = fir.read_ir()
except OSError:
continue
if not ALT_OVERLAY:
fir.draw_ir(img, ir, hint=drawing_hint)
else:
extra_fb.clear()
fir.draw_ir(extra_fb, ir, hint=drawing_hint)
img.blend(extra_fb, alpha=128)
img.draw_string((8, 0), "Ta: %0.2f C" % ta, color=(255, 0, 0), mono_space=False)
img.draw_string(
(8, 8), "To min: %0.2f C" % to_min, color=(255, 0, 0), mono_space=False
)
img.draw_string(
(8, 16), "To max: %0.2f C" % to_max, color=(255, 0, 0), mono_space=False
)
lcd.write(img)
img.to_jpeg(quality=90)
print(clock.fps())