mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Tried to emulate Arduino's 11 folders... I'd perfer to have all the shield scripts in one folder... but, that might not make sense. I don't really want one script per folder however. So, I might merge some more stuff in the future. I have a grand idea here that will become evident as I work though the examples. Anyway, the current structure is not final. It will be in flux for a little while. As for Git History, folder history is the best we're going to get. Git and GitHub don't seem to deal with moves too well.
60 lines
1.5 KiB
Python
60 lines
1.5 KiB
Python
# Thermopile Shield Demo 2
|
|
#
|
|
# Note: To run this example you will need a Thermopile Shield for your OpenMV
|
|
# Cam and a LCD Shield.
|
|
|
|
import sensor, image, time, fir, lcd
|
|
|
|
# Reset sensor
|
|
sensor.reset()
|
|
|
|
# Set sensor settings
|
|
sensor.set_contrast(1)
|
|
sensor.set_brightness(0)
|
|
sensor.set_saturation(2)
|
|
sensor.set_pixformat(sensor.RGB565)
|
|
sensor.set_framesize(sensor.QQVGA2)
|
|
|
|
# The following registers fine-tune the image
|
|
# sensor window to align it with the FIR sensor.
|
|
if (sensor.get_id() == sensor.OV2640):
|
|
sensor.__write_reg(0xFF, 0x01) # switch to reg bank
|
|
sensor.__write_reg(0x17, 0x19) # set HSTART
|
|
sensor.__write_reg(0x18, 0x43) # set HSTOP
|
|
|
|
# Initialize the thermal sensor
|
|
fir.init()
|
|
|
|
# Initialize the lcd sensor
|
|
lcd.init()
|
|
|
|
# FPS clock
|
|
clock = time.clock()
|
|
|
|
while(True):
|
|
clock.tick()
|
|
|
|
# Capture an image
|
|
image = sensor.snapshot()
|
|
|
|
# Capture FIR data
|
|
# ta: Ambient temperature
|
|
# ir: Object temperatures (IR array)
|
|
# to_min: Minimum object temperature
|
|
# to_max: Maximum object temperature
|
|
ta, ir, to_min, to_max = fir.read_ir()
|
|
|
|
# Draw IR data on the framebuffer
|
|
fir.draw_ir(image, ir)
|
|
|
|
# Draw ambient, min and max temperatures.
|
|
image.draw_string(0, 0, "Ta: %0.2f"%ta, color = (0xFF, 0x00, 0x00))
|
|
image.draw_string(0, 8, "To min: %0.2f"%(to_min+ta), color = (0xFF, 0x00, 0x00))
|
|
image.draw_string(0, 16, "To max: %0.2f"%(to_max+ta), color = (0xFF, 0x00, 0x00))
|
|
|
|
# Display image on LCD
|
|
lcd.display(image)
|
|
|
|
# Print FPS.
|
|
print(clock.fps())
|