Example explanation 27-Lepton->lepton_get_object_temp_lcd Get the object temperature LCD display
import sensor, image, time, math, lcd
threshold_list = [(200, 255)]
min_temp_in_celsius = 20.0
max_temp_in_celsius = 35.0
print("Resetting Lepton...")
sensor.reset()
sensor.ioctl(sensor.IOCTL_LEPTON_SET_MEASUREMENT_MODE, True)
sensor.ioctl(sensor.IOCTL_LEPTON_SET_MEASUREMENT_RANGE, min_temp_in_celsius, max_temp_in_celsius)
print("Lepton Res (%dx%d)" % (sensor.ioctl(sensor.IOCTL_LEPTON_GET_WIDTH),
sensor.ioctl(sensor.IOCTL_LEPTON_GET_HEIGHT)))
print("Radiometry Available: " + ("Yes" if sensor.ioctl(sensor.IOCTL_LEPTON_GET_RADIOMETRY) else "No"))
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.LCD)
sensor.skip_frames(time=5000)
clock = time.clock()
lcd.init()
def map_g_to_temp(g):
return ((g * (max_temp_in_celsius - min_temp_in_celsius)) / 255.0) + min_temp_in_celsius
while(True):
clock.tick()
img = sensor.snapshot()
for blob in img.find_blobs(threshold_list, pixels_threshold=200, area_threshold=200, merge=True):
stats = img.get_statistics(thresholds=threshold_list, roi=blob.rect())
img.draw_rectangle(blob.rect())
img.draw_cross(blob.cx(), blob.cy())
img.draw_string(blob.x(), blob.y() - 10, "%.2f C" % map_g_to_temp(stats.mean()), mono_space=False)
lcd.display(img)
print("FPS %f - Lepton Temp: %f C" % (clock.fps(), sensor.ioctl(sensor.IOCTL_LEPTON_GET_FPA_TEMPERATURE)))