mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Add auto scanning and update examples
This commit is contained in:
parent
0f2a8d7c53
commit
da6c1a6ed9
@ -1,4 +1,4 @@
|
||||
# AMG8833 Camera Demo
|
||||
# Thermal Camera Demo
|
||||
#
|
||||
# This example shows off how to overlay a heatmap onto your OpenMV Cam's
|
||||
# live video output from the main camera.
|
||||
@ -8,9 +8,19 @@ import image, time, fir
|
||||
drawing_hint = image.BICUBIC # or image.BILINEAR or 0 (nearest neighbor)
|
||||
|
||||
# Initialize the thermal sensor
|
||||
fir.init(type=fir.FIR_AMG8833)
|
||||
w = fir.width() * 20
|
||||
h = fir.height() * 20
|
||||
fir.init()
|
||||
w = fir.width()
|
||||
h = fir.height()
|
||||
|
||||
if (fir.type() == fir.FIR_MLX90621):
|
||||
w = w * 5
|
||||
h = h * 5
|
||||
elif (fir.type() == fir.FIR_MLX90640):
|
||||
w = w * 5
|
||||
h = h * 5
|
||||
elif (fir.type() == fir.FIR_AMG8833):
|
||||
w = w * 10
|
||||
h = h * 10
|
||||
|
||||
# FPS clock
|
||||
clock = time.clock()
|
||||
@ -1,29 +0,0 @@
|
||||
# MLX90621 Camera Demo
|
||||
#
|
||||
# This example shows off how to overlay a heatmap onto your OpenMV Cam's
|
||||
# live video output from the main camera.
|
||||
|
||||
import image, time, fir
|
||||
|
||||
drawing_hint = image.BICUBIC # or image.BILINEAR or 0 (nearest neighbor)
|
||||
|
||||
# Initialize the thermal sensor
|
||||
fir.init(type=fir.FIR_MLX90621)
|
||||
w = fir.width() * 20
|
||||
h = fir.height() * 20
|
||||
|
||||
# FPS clock
|
||||
clock = time.clock()
|
||||
|
||||
while (True):
|
||||
clock.tick()
|
||||
|
||||
try:
|
||||
img = fir.snapshot(x_size=w, y_size=h,
|
||||
color_palette=fir.PALETTE_IRONBOW, hint=drawing_hint,
|
||||
copy_to_fb=True)
|
||||
except OSError:
|
||||
continue
|
||||
|
||||
# Print FPS.
|
||||
print(clock.fps())
|
||||
@ -1,60 +0,0 @@
|
||||
# MLX90621 Overlay Demo
|
||||
#
|
||||
# This example shows off how to overlay a heatmap onto your OpenMV Cam's
|
||||
# live video output from the main camera.
|
||||
|
||||
import sensor, image, time, fir
|
||||
|
||||
drawing_hint = image.BICUBIC # or image.BILINEAR or 0 (nearest neighbor)
|
||||
|
||||
ALT_OVERLAY = False # Set to True to allocate a second ir image.
|
||||
|
||||
sensor.reset()
|
||||
sensor.set_pixformat(sensor.RGB565)
|
||||
sensor.set_framesize(sensor.QQVGA)
|
||||
sensor.skip_frames(time = 2000)
|
||||
|
||||
# Initialize the thermal sensor
|
||||
fir.init(type=fir.FIR_MLX90621)
|
||||
|
||||
# Allocate another frame buffer for smoother video.
|
||||
extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.RGB565)
|
||||
|
||||
# FPS clock
|
||||
clock = time.clock()
|
||||
|
||||
while (True):
|
||||
clock.tick()
|
||||
|
||||
# Capture an image
|
||||
img = sensor.snapshot()
|
||||
|
||||
# Capture FIR data
|
||||
# ta: Ambient temperature
|
||||
# ir: Object temperatures (IR array)
|
||||
# to_min: Minimum object temperature
|
||||
# to_max: Maximum object temperature
|
||||
try:
|
||||
ta, ir, to_min, to_max = fir.read_ir()
|
||||
except OSError:
|
||||
continue
|
||||
|
||||
if not ALT_OVERLAY:
|
||||
# Scale the image and belnd it with the framebuffer
|
||||
fir.draw_ir(img, ir, hint=drawing_hint)
|
||||
else:
|
||||
# Create a secondary image and then blend into the frame buffer.
|
||||
extra_fb.clear()
|
||||
fir.draw_ir(extra_fb, ir, alpha=256, hint=drawing_hint)
|
||||
img.blend(extra_fb, alpha=128)
|
||||
|
||||
# Draw ambient, min and max temperatures.
|
||||
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)
|
||||
|
||||
# Force high quality streaming...
|
||||
img.compress(quality=90)
|
||||
|
||||
# Print FPS.
|
||||
print(clock.fps())
|
||||
@ -1,64 +0,0 @@
|
||||
# MLX90621 Overlay Demo
|
||||
#
|
||||
# This example shows off how to overlay a heatmap onto your OpenMV Cam's
|
||||
# live video output from the main camera.
|
||||
|
||||
import sensor, image, time, fir, lcd
|
||||
|
||||
drawing_hint = image.BICUBIC # or image.BILINEAR or 0 (nearest neighbor)
|
||||
|
||||
ALT_OVERLAY = False # Set to True to allocate a second ir image.
|
||||
|
||||
sensor.reset()
|
||||
sensor.set_pixformat(sensor.RGB565)
|
||||
sensor.set_framesize(sensor.QQVGA2)
|
||||
sensor.skip_frames(time = 2000)
|
||||
|
||||
# Initialize the thermal sensor
|
||||
fir.init(type=fir.FIR_MLX90621)
|
||||
|
||||
# Init the lcd.
|
||||
lcd.init()
|
||||
|
||||
# Allocate another frame buffer for smoother video.
|
||||
extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.RGB565)
|
||||
|
||||
# FPS clock
|
||||
clock = time.clock()
|
||||
|
||||
while (True):
|
||||
clock.tick()
|
||||
|
||||
# Capture an image
|
||||
img = sensor.snapshot()
|
||||
|
||||
# Capture FIR data
|
||||
# ta: Ambient temperature
|
||||
# ir: Object temperatures (IR array)
|
||||
# to_min: Minimum object temperature
|
||||
# to_max: Maximum object temperature
|
||||
try:
|
||||
ta, ir, to_min, to_max = fir.read_ir()
|
||||
except OSError:
|
||||
continue
|
||||
|
||||
if not ALT_OVERLAY:
|
||||
# Scale the image and belnd it with the framebuffer
|
||||
fir.draw_ir(img, ir, hint=drawing_hint)
|
||||
else:
|
||||
# Create a secondary image and then blend into the frame buffer.
|
||||
extra_fb.clear()
|
||||
fir.draw_ir(extra_fb, ir, alpha=256, hint=drawing_hint)
|
||||
img.blend(extra_fb, alpha=128)
|
||||
|
||||
# Draw ambient, min and max temperatures.
|
||||
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.display(img)
|
||||
# Force high quality streaming...
|
||||
img.compress(quality=90)
|
||||
|
||||
# Print FPS.
|
||||
print(clock.fps())
|
||||
@ -1,60 +0,0 @@
|
||||
# MLX90640 Overlay Demo
|
||||
#
|
||||
# This example shows off how to overlay a heatmap onto your OpenMV Cam's
|
||||
# live video output from the main camera.
|
||||
|
||||
import sensor, image, time, fir
|
||||
|
||||
drawing_hint = image.BICUBIC # or image.BILINEAR or 0 (nearest neighbor)
|
||||
|
||||
ALT_OVERLAY = False # Set to True to allocate a second ir image.
|
||||
|
||||
sensor.reset()
|
||||
sensor.set_pixformat(sensor.RGB565)
|
||||
sensor.set_framesize(sensor.QQVGA)
|
||||
sensor.skip_frames(time = 2000)
|
||||
|
||||
# Initialize the thermal sensor
|
||||
fir.init(type=fir.FIR_MLX90640, refresh=32) # 16Hz, 32Hz or 64Hz.
|
||||
|
||||
# Allocate another frame buffer for smoother video.
|
||||
extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.RGB565)
|
||||
|
||||
# FPS clock
|
||||
clock = time.clock()
|
||||
|
||||
while (True):
|
||||
clock.tick()
|
||||
|
||||
# Capture an image
|
||||
img = sensor.snapshot()
|
||||
|
||||
# Capture FIR data
|
||||
# ta: Ambient temperature
|
||||
# ir: Object temperatures (IR array)
|
||||
# to_min: Minimum object temperature
|
||||
# to_max: Maximum object temperature
|
||||
try:
|
||||
ta, ir, to_min, to_max = fir.read_ir()
|
||||
except OSError:
|
||||
continue
|
||||
|
||||
if not ALT_OVERLAY:
|
||||
# Scale the image and belnd it with the framebuffer
|
||||
fir.draw_ir(img, ir, hint=drawing_hint)
|
||||
else:
|
||||
# Create a secondary image and then blend into the frame buffer.
|
||||
extra_fb.clear()
|
||||
fir.draw_ir(extra_fb, ir, alpha=256, hint=drawing_hint)
|
||||
img.blend(extra_fb, alpha=128)
|
||||
|
||||
# Draw ambient, min and max temperatures.
|
||||
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)
|
||||
|
||||
# Force high quality streaming...
|
||||
img.compress(quality=90)
|
||||
|
||||
# Print FPS.
|
||||
print(clock.fps())
|
||||
@ -1,64 +0,0 @@
|
||||
# MLX90640 Overlay Demo
|
||||
#
|
||||
# This example shows off how to overlay a heatmap onto your OpenMV Cam's
|
||||
# live video output from the main camera.
|
||||
|
||||
import sensor, image, time, fir, lcd
|
||||
|
||||
drawing_hint = image.BICUBIC # or image.BILINEAR or 0 (nearest neighbor)
|
||||
|
||||
ALT_OVERLAY = False # Set to True to allocate a second ir image.
|
||||
|
||||
sensor.reset()
|
||||
sensor.set_pixformat(sensor.RGB565)
|
||||
sensor.set_framesize(sensor.QQVGA2)
|
||||
sensor.skip_frames(time = 2000)
|
||||
|
||||
# Initialize the thermal sensor
|
||||
fir.init(type=fir.FIR_MLX90640, refresh=32) # 16Hz, 32Hz or 64Hz.
|
||||
|
||||
# Init the lcd.
|
||||
lcd.init()
|
||||
|
||||
# Allocate another frame buffer for smoother video.
|
||||
extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.RGB565)
|
||||
|
||||
# FPS clock
|
||||
clock = time.clock()
|
||||
|
||||
while (True):
|
||||
clock.tick()
|
||||
|
||||
# Capture an image
|
||||
img = sensor.snapshot()
|
||||
|
||||
# Capture FIR data
|
||||
# ta: Ambient temperature
|
||||
# ir: Object temperatures (IR array)
|
||||
# to_min: Minimum object temperature
|
||||
# to_max: Maximum object temperature
|
||||
try:
|
||||
ta, ir, to_min, to_max = fir.read_ir()
|
||||
except OSError:
|
||||
continue
|
||||
|
||||
if not ALT_OVERLAY:
|
||||
# Scale the image and belnd it with the framebuffer
|
||||
fir.draw_ir(img, ir, hint=drawing_hint)
|
||||
else:
|
||||
# Create a secondary image and then blend into the frame buffer.
|
||||
extra_fb.clear()
|
||||
fir.draw_ir(extra_fb, ir, alpha=256, hint=drawing_hint)
|
||||
img.blend(extra_fb, alpha=128)
|
||||
|
||||
# Draw ambient, min and max temperatures.
|
||||
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.display(img)
|
||||
# Force high quality streaming...
|
||||
img.compress(quality=90)
|
||||
|
||||
# Print FPS.
|
||||
print(clock.fps())
|
||||
@ -1,4 +1,4 @@
|
||||
# MLX90640 Camera Demo
|
||||
# Thermal Camera Demo
|
||||
#
|
||||
# This example shows off how to overlay a heatmap onto your OpenMV Cam's
|
||||
# live video output from the main camera.
|
||||
@ -8,9 +8,19 @@ import image, time, fir
|
||||
drawing_hint = image.BICUBIC # or image.BILINEAR or 0 (nearest neighbor)
|
||||
|
||||
# Initialize the thermal sensor
|
||||
fir.init(type=fir.FIR_MLX90640)
|
||||
w = fir.width() * 10
|
||||
h = fir.height() * 10
|
||||
fir.init()
|
||||
w = fir.width()
|
||||
h = fir.height()
|
||||
|
||||
if (fir.type() == fir.FIR_MLX90621):
|
||||
w = w * 10
|
||||
h = h * 10
|
||||
elif (fir.type() == fir.FIR_MLX90640):
|
||||
w = w * 10
|
||||
h = h * 10
|
||||
elif (fir.type() == fir.FIR_AMG8833):
|
||||
w = w * 20
|
||||
h = h * 20
|
||||
|
||||
# FPS clock
|
||||
clock = time.clock()
|
||||
@ -1,4 +1,4 @@
|
||||
# AMG8833 Overlay Demo
|
||||
# Thermal Overlay Demo
|
||||
#
|
||||
# This example shows off how to overlay a heatmap onto your OpenMV Cam's
|
||||
# live video output from the main camera.
|
||||
@ -15,7 +15,7 @@ sensor.set_framesize(sensor.QQVGA)
|
||||
sensor.skip_frames(time = 2000)
|
||||
|
||||
# Initialize the thermal sensor
|
||||
fir.init(type=fir.FIR_AMG8833)
|
||||
fir.init()
|
||||
|
||||
# Allocate another frame buffer for smoother video.
|
||||
extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.RGB565)
|
||||
@ -1,4 +1,4 @@
|
||||
# AMG8833 Overlay Demo
|
||||
# Thermal Overlay Demo
|
||||
#
|
||||
# This example shows off how to overlay a heatmap onto your OpenMV Cam's
|
||||
# live video output from the main camera.
|
||||
@ -15,7 +15,7 @@ sensor.set_framesize(sensor.QQVGA2)
|
||||
sensor.skip_frames(time = 2000)
|
||||
|
||||
# Initialize the thermal sensor
|
||||
fir.init(type=fir.FIR_AMG8833)
|
||||
fir.init()
|
||||
|
||||
# Init the lcd.
|
||||
lcd.init()
|
||||
@ -31,7 +31,7 @@
|
||||
#include "py_fir_lepton.h"
|
||||
#endif
|
||||
|
||||
#define MLX90621_ADDR 0xC0
|
||||
#define MLX90621_ADDR 0x50
|
||||
#define MLX90621_WIDTH 16
|
||||
#define MLX90621_HEIGHT 4
|
||||
#define MLX90621_EEPROM_DATA_SIZE 256
|
||||
@ -51,6 +51,8 @@
|
||||
#define AMG8833_TEMPERATURE_REGISTER 0x80
|
||||
#define AMG8833_INITIAL_RESET_VALUE 0x3F
|
||||
|
||||
#define LEPTON_ADDR 0x54
|
||||
|
||||
#define AMG8833_12_TO_16(value) \
|
||||
({ \
|
||||
__typeof__ (value) __value = (value); \
|
||||
@ -284,7 +286,41 @@ mp_obj_t py_fir_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
py_fir_deinit();
|
||||
bool first_init = true;
|
||||
switch (py_helper_keyword_int(n_args, args, 0, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_type), FIR_MLX90621)) {
|
||||
int type = py_helper_keyword_int(n_args, args, 0, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_type), -1);
|
||||
if (type == -1) {
|
||||
cambus_init(&fir_bus, FIR_I2C_ID, CAMBUS_SPEED_STANDARD);
|
||||
switch (cambus_scan(&fir_bus)) {
|
||||
#if (OMV_ENABLE_FIR_MLX90621 == 1)
|
||||
case (MLX90621_ADDR << 1): {
|
||||
type = FIR_MLX90621;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#if (OMV_ENABLE_FIR_MLX90640 == 1)
|
||||
case (MLX90640_ADDR << 1): {
|
||||
type = FIR_MLX90640;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#if (OMV_ENABLE_FIR_AMG8833 == 1)
|
||||
case AMG8833_ADDR: {
|
||||
type = FIR_AMG8833;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#if (OMV_ENABLE_FIR_LEPTON == 1)
|
||||
case LEPTON_ADDR: {
|
||||
type = FIR_LEPTON;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default: {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "No device type found!"));
|
||||
}
|
||||
}
|
||||
cambus_deinit(&fir_bus);
|
||||
}
|
||||
switch (type) {
|
||||
case FIR_NONE: {
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user