import sensor, mlx, time # Initialize the MLX module mlx.init(mlx.IR_REFRESH_64HZ) # 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.QQVGA) # 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 # FPS clock clock = time.clock() # Ambient temperature ta = 0.0 # Minimum object temperature to_min = 0.0 # Maximum object temperature to_max = 0.0
import sensor, lcd, mlx, time, led, gpio lcd.init() mlx.init() sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) thermal_on = True def switch_cb(line): global thermal_on if (line == 9): led.toggle(led.IR) if (line == 12): thermal_on = not thermal_on gpio.EXTI(gpio.PB2, switch_cb) gpio.EXTI(gpio.PB3, switch_cb) clock = time.clock() while (True): clock.tick() rgb = sensor.snapshot() rgb = rgb.scaled((128, 160)) if (thermal_on): ir = mlx.read() x = ir.rainbow() x = ir.scale((64, 160))
import sensor, lcd, mlx, time, led, gpio lcd.init() mlx.init() sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) thermal_on = True def switch_cb(line): global thermal_on if (line == 9): led.toggle(led.IR) if (line == 12): thermal_on = not thermal_on gpio.EXTI(gpio.PB2, switch_cb) gpio.EXTI(gpio.PB3, switch_cb) clock = time.clock() while (True): clock.tick() rgb = sensor.snapshot() rgb = rgb.scaled((128, 160)) if (thermal_on): ir = mlx.read() x=ir.rainbow() x=ir.scale((64, 160)) #rgb.blend(ir, (rgb.w/2-ir.w/2, rgb.h/2-ir.h/2), 0.4) rgb.blend(ir, (32, 0, 0.6))