From 3fc2480126126361a9f4945c150c589cba4b5292 Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Sun, 29 Oct 2023 23:30:16 -0700 Subject: [PATCH] modules: Move palette constants to the image module. --- .../01-Camera/05-FLIR-Lepton/lepton_get_object_temp_color.py | 3 ++- .../05-FLIR-Lepton/lepton_get_object_temp_color_lcd.py | 3 ++- .../05-FLIR-Lepton/lepton_hotspot_rgb565_color_tracking.py | 3 ++- .../lepton_hotspot_rgb565_color_tracking_lcd.py | 3 ++- .../lepton_target_temp_hotspot_rgb565_color_tracking.py | 3 ++- .../image_drawing_alpha_blending_with_color_table_test.py | 2 +- .../image_drawing_alpha_table_with_color_table_test.py | 2 +- .../Nano-33-BLE-Sense/53-Thermal/thermal_camera.py | 2 +- .../Nano-RP2040/53-Thermal/thermal_camera.py | 2 +- .../50-OpenMV-Boards/54-Thermopile-Shield/thermal_camera.py | 2 +- src/omv/boards/OPENMVPT/main_py.h | 2 +- src/omv/modules/py_fir.c | 4 ---- src/omv/modules/py_image.c | 2 ++ src/omv/modules/py_sensor.c | 4 ---- 14 files changed, 18 insertions(+), 19 deletions(-) diff --git a/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_get_object_temp_color.py b/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_get_object_temp_color.py index 2640b12b4..16d6fb1f4 100644 --- a/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_get_object_temp_color.py +++ b/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_get_object_temp_color.py @@ -23,6 +23,7 @@ import sensor import time +import image # Color Tracking Thresholds (Grayscale Min, Grayscale Max) threshold_list = [(200, 255)] @@ -86,7 +87,7 @@ while True: ), ) ) - img.to_rainbow(color_palette=sensor.PALETTE_IRONBOW) # color it + img.to_rainbow(color_palette=image.PALETTE_IRONBOW) # color it # Draw stuff on the colored image for blob in blobs: img.draw_rectangle(blob.rect()) diff --git a/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_get_object_temp_color_lcd.py b/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_get_object_temp_color_lcd.py index 9699925c1..10309c97b 100644 --- a/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_get_object_temp_color_lcd.py +++ b/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_get_object_temp_color_lcd.py @@ -24,6 +24,7 @@ import sensor import time import display +import image # Color Tracking Thresholds (Grayscale Min, Grayscale Max) threshold_list = [(200, 255)] @@ -88,7 +89,7 @@ while True: ), ) ) - img.to_rainbow(color_palette=sensor.PALETTE_IRONBOW) # color it + img.to_rainbow(color_palette=image.PALETTE_IRONBOW) # color it # Draw stuff on the colored image for blob in blobs: img.draw_rectangle(blob.rect()) diff --git a/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_hotspot_rgb565_color_tracking.py b/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_hotspot_rgb565_color_tracking.py index 43c00d20a..bf172be43 100644 --- a/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_hotspot_rgb565_color_tracking.py +++ b/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_hotspot_rgb565_color_tracking.py @@ -13,6 +13,7 @@ import sensor import time +import image # Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max) threshold_list = [(70, 100, -30, 40, 20, 100)] @@ -32,7 +33,7 @@ print( + ("Yes" if sensor.ioctl(sensor.IOCTL_LEPTON_GET_RADIOMETRY) else "No") ) # Make the color palette cool -sensor.set_color_palette(sensor.PALETTE_IRONBOW) +sensor.set_color_palette(image.PALETTE_IRONBOW) sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) diff --git a/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_hotspot_rgb565_color_tracking_lcd.py b/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_hotspot_rgb565_color_tracking_lcd.py index 40a230ffd..a744f32bc 100644 --- a/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_hotspot_rgb565_color_tracking_lcd.py +++ b/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_hotspot_rgb565_color_tracking_lcd.py @@ -14,6 +14,7 @@ import sensor import time import display +import image # Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max) threshold_list = [(70, 100, -30, 40, 20, 100)] @@ -33,7 +34,7 @@ print( + ("Yes" if sensor.ioctl(sensor.IOCTL_LEPTON_GET_RADIOMETRY) else "No") ) # Make the color palette cool -sensor.set_color_palette(sensor.PALETTE_IRONBOW) +sensor.set_color_palette(image.PALETTE_IRONBOW) sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.LCD) diff --git a/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_target_temp_hotspot_rgb565_color_tracking.py b/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_target_temp_hotspot_rgb565_color_tracking.py index cc9f6c9b1..2c8342a5f 100644 --- a/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_target_temp_hotspot_rgb565_color_tracking.py +++ b/scripts/examples/01-Camera/05-FLIR-Lepton/lepton_target_temp_hotspot_rgb565_color_tracking.py @@ -23,6 +23,7 @@ import sensor import time +import image # Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max) threshold_list = [(70, 100, -30, 40, 20, 100)] @@ -50,7 +51,7 @@ print( + ("Yes" if sensor.ioctl(sensor.IOCTL_LEPTON_GET_RADIOMETRY) else "No") ) # Make the color palette cool -sensor.set_color_palette(sensor.PALETTE_IRONBOW) +sensor.set_color_palette(image.PALETTE_IRONBOW) sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) diff --git a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_blending_with_color_table_test.py b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_blending_with_color_table_test.py index eeff4610b..4ad006f75 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_blending_with_color_table_test.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_blending_with_color_table_test.py @@ -77,7 +77,7 @@ while True: y_bounce, rgb_channel=-1, alpha=alpha_value // alpha_div, - color_palette=sensor.PALETTE_IRONBOW, + color_palette=image.PALETTE_IRONBOW, hint=hint | image.CENTER, ) diff --git a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_table_with_color_table_test.py b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_table_with_color_table_test.py index 9538c4dbc..b7a843f8b 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_table_with_color_table_test.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_table_with_color_table_test.py @@ -81,7 +81,7 @@ while True: y_bounce, rgb_channel=-1, alpha=alpha_value // alpha_div, - color_palette=sensor.PALETTE_IRONBOW, + color_palette=image.PALETTE_IRONBOW, alpha_palette=alpha_lut, hint=hint | image.CENTER, ) diff --git a/scripts/examples/50-Arduino-Boards/Nano-33-BLE-Sense/53-Thermal/thermal_camera.py b/scripts/examples/50-Arduino-Boards/Nano-33-BLE-Sense/53-Thermal/thermal_camera.py index c5d3a5ef2..08750ff1b 100644 --- a/scripts/examples/50-Arduino-Boards/Nano-33-BLE-Sense/53-Thermal/thermal_camera.py +++ b/scripts/examples/50-Arduino-Boards/Nano-33-BLE-Sense/53-Thermal/thermal_camera.py @@ -41,7 +41,7 @@ while True: img = fir.snapshot( x_size=w, y_size=h, - color_palette=fir.PALETTE_IRONBOW, + color_palette=image.PALETTE_IRONBOW, hint=drawing_hint, copy_to_fb=True, ) diff --git a/scripts/examples/50-Arduino-Boards/Nano-RP2040/53-Thermal/thermal_camera.py b/scripts/examples/50-Arduino-Boards/Nano-RP2040/53-Thermal/thermal_camera.py index 5bc74cf30..7980afc54 100644 --- a/scripts/examples/50-Arduino-Boards/Nano-RP2040/53-Thermal/thermal_camera.py +++ b/scripts/examples/50-Arduino-Boards/Nano-RP2040/53-Thermal/thermal_camera.py @@ -29,7 +29,7 @@ while True: img = fir.snapshot( x_size=w, y_size=h, - color_palette=fir.PALETTE_IRONBOW, + color_palette=image.PALETTE_IRONBOW, hint=drawing_hint, copy_to_fb=True, ) diff --git a/scripts/examples/50-OpenMV-Boards/54-Thermopile-Shield/thermal_camera.py b/scripts/examples/50-OpenMV-Boards/54-Thermopile-Shield/thermal_camera.py index fc7c17227..0865864e6 100644 --- a/scripts/examples/50-OpenMV-Boards/54-Thermopile-Shield/thermal_camera.py +++ b/scripts/examples/50-OpenMV-Boards/54-Thermopile-Shield/thermal_camera.py @@ -41,7 +41,7 @@ while True: img = fir.snapshot( x_size=w, y_size=h, - color_palette=fir.PALETTE_IRONBOW, + color_palette=image.PALETTE_IRONBOW, hint=drawing_hint, copy_to_fb=True, ) diff --git a/src/omv/boards/OPENMVPT/main_py.h b/src/omv/boards/OPENMVPT/main_py.h index dc3e8e09e..33f0b9730 100644 --- a/src/omv/boards/OPENMVPT/main_py.h +++ b/src/omv/boards/OPENMVPT/main_py.h @@ -57,7 +57,7 @@ static const char fresh_main_py[] = " x_scale = img.width() / fir_img.width()\n" " y_scale = img.height() / fir_img.height()\n" " img.draw_image(fir_img, 0, 0, x_scale = x_scale, y_scale = y_scale,\n" - " color_palette = sensor.PALETTE_IRONBOW,\n" + " color_palette = image.PALETTE_IRONBOW,\n" " alpha_palette = alpha_pal,\n" " hint = image.BICUBIC)\n" "\n" diff --git a/src/omv/modules/py_fir.c b/src/omv/modules/py_fir.c index 4fac67bea..8e7bef968 100644 --- a/src/omv/modules/py_fir.c +++ b/src/omv/modules/py_fir.c @@ -1243,10 +1243,6 @@ STATIC const mp_rom_map_elem_t globals_dict_table[] = { #if (OMV_ENABLE_FIR_LEPTON == 1) { MP_ROM_QSTR(MP_QSTR_FIR_LEPTON), MP_ROM_INT(FIR_LEPTON) }, #endif - { MP_ROM_QSTR(MP_QSTR_PALETTE_RAINBOW), MP_ROM_INT(COLOR_PALETTE_RAINBOW) }, - { MP_ROM_QSTR(MP_QSTR_PALETTE_IRONBOW), MP_ROM_INT(COLOR_PALETTE_IRONBOW) }, - { MP_ROM_QSTR(MP_QSTR_GRAYSCALE), MP_ROM_INT(PIXFORMAT_GRAYSCALE) }, - { MP_ROM_QSTR(MP_QSTR_RGB565), MP_ROM_INT(PIXFORMAT_RGB565) }, { MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&py_fir_init_obj) }, { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&py_fir_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR_type), MP_ROM_PTR(&py_fir_type_obj) }, diff --git a/src/omv/modules/py_image.c b/src/omv/modules/py_image.c index 69d0e0632..b65614858 100644 --- a/src/omv/modules/py_image.c +++ b/src/omv/modules/py_image.c @@ -7210,6 +7210,8 @@ static const mp_rom_map_elem_t globals_dict_table[] = { {MP_ROM_QSTR(MP_QSTR_YUV422), MP_ROM_INT(PIXFORMAT_YUV422)}, /* 2BPP/YUV422*/ {MP_ROM_QSTR(MP_QSTR_JPEG), MP_ROM_INT(PIXFORMAT_JPEG)}, /* JPEG/COMPRESSED*/ {MP_ROM_QSTR(MP_QSTR_PNG), MP_ROM_INT(PIXFORMAT_PNG)}, /* PNG/COMPRESSED*/ + {MP_ROM_QSTR(MP_QSTR_PALETTE_RAINBOW), MP_ROM_INT(COLOR_PALETTE_RAINBOW)}, + {MP_ROM_QSTR(MP_QSTR_PALETTE_IRONBOW), MP_ROM_INT(COLOR_PALETTE_IRONBOW)}, {MP_ROM_QSTR(MP_QSTR_AREA), MP_ROM_INT(IMAGE_HINT_AREA)}, {MP_ROM_QSTR(MP_QSTR_BILINEAR), MP_ROM_INT(IMAGE_HINT_BILINEAR)}, {MP_ROM_QSTR(MP_QSTR_BICUBIC), MP_ROM_INT(IMAGE_HINT_BICUBIC)}, diff --git a/src/omv/modules/py_sensor.c b/src/omv/modules/py_sensor.c index 78e310888..096bb137c 100644 --- a/src/omv/modules/py_sensor.c +++ b/src/omv/modules/py_sensor.c @@ -1097,10 +1097,6 @@ STATIC const mp_map_elem_t globals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_WQXGA), MP_OBJ_NEW_SMALL_INT(FRAMESIZE_WQXGA)}, /* 2560x1600 */ { MP_OBJ_NEW_QSTR(MP_QSTR_WQXGA2), MP_OBJ_NEW_SMALL_INT(FRAMESIZE_WQXGA2)}, /* 2592x1944 */ - // Color Palettes - { MP_OBJ_NEW_QSTR(MP_QSTR_PALETTE_RAINBOW), MP_OBJ_NEW_SMALL_INT(COLOR_PALETTE_RAINBOW)}, - { MP_OBJ_NEW_QSTR(MP_QSTR_PALETTE_IRONBOW), MP_OBJ_NEW_SMALL_INT(COLOR_PALETTE_IRONBOW)}, - // IOCTLs { MP_OBJ_NEW_QSTR(MP_QSTR_IOCTL_SET_READOUT_WINDOW), MP_OBJ_NEW_SMALL_INT(IOCTL_SET_READOUT_WINDOW)}, { MP_OBJ_NEW_QSTR(MP_QSTR_IOCTL_GET_READOUT_WINDOW), MP_OBJ_NEW_SMALL_INT(IOCTL_GET_READOUT_WINDOW)},