Merge pull request #2006 from kwagyeman/kwabena/refactor_palette_constants

modules: Move palette constants to the image module.
This commit is contained in:
Ibrahim Abdelkader 2023-10-30 17:44:01 +02:00 committed by GitHub
commit a1b95152cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 18 additions and 19 deletions

View File

@ -23,6 +23,7 @@
import sensor import sensor
import time import time
import image
# Color Tracking Thresholds (Grayscale Min, Grayscale Max) # Color Tracking Thresholds (Grayscale Min, Grayscale Max)
threshold_list = [(200, 255)] 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 # Draw stuff on the colored image
for blob in blobs: for blob in blobs:
img.draw_rectangle(blob.rect()) img.draw_rectangle(blob.rect())

View File

@ -24,6 +24,7 @@
import sensor import sensor
import time import time
import display import display
import image
# Color Tracking Thresholds (Grayscale Min, Grayscale Max) # Color Tracking Thresholds (Grayscale Min, Grayscale Max)
threshold_list = [(200, 255)] 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 # Draw stuff on the colored image
for blob in blobs: for blob in blobs:
img.draw_rectangle(blob.rect()) img.draw_rectangle(blob.rect())

View File

@ -13,6 +13,7 @@
import sensor import sensor
import time import time
import image
# Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max) # Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max)
threshold_list = [(70, 100, -30, 40, 20, 100)] threshold_list = [(70, 100, -30, 40, 20, 100)]
@ -32,7 +33,7 @@ print(
+ ("Yes" if sensor.ioctl(sensor.IOCTL_LEPTON_GET_RADIOMETRY) else "No") + ("Yes" if sensor.ioctl(sensor.IOCTL_LEPTON_GET_RADIOMETRY) else "No")
) )
# Make the color palette cool # 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_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA) sensor.set_framesize(sensor.QQVGA)

View File

@ -14,6 +14,7 @@
import sensor import sensor
import time import time
import display import display
import image
# Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max) # Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max)
threshold_list = [(70, 100, -30, 40, 20, 100)] threshold_list = [(70, 100, -30, 40, 20, 100)]
@ -33,7 +34,7 @@ print(
+ ("Yes" if sensor.ioctl(sensor.IOCTL_LEPTON_GET_RADIOMETRY) else "No") + ("Yes" if sensor.ioctl(sensor.IOCTL_LEPTON_GET_RADIOMETRY) else "No")
) )
# Make the color palette cool # 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_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.LCD) sensor.set_framesize(sensor.LCD)

View File

@ -23,6 +23,7 @@
import sensor import sensor
import time import time
import image
# Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max) # Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max)
threshold_list = [(70, 100, -30, 40, 20, 100)] threshold_list = [(70, 100, -30, 40, 20, 100)]
@ -50,7 +51,7 @@ print(
+ ("Yes" if sensor.ioctl(sensor.IOCTL_LEPTON_GET_RADIOMETRY) else "No") + ("Yes" if sensor.ioctl(sensor.IOCTL_LEPTON_GET_RADIOMETRY) else "No")
) )
# Make the color palette cool # 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_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA) sensor.set_framesize(sensor.QQVGA)

View File

@ -77,7 +77,7 @@ while True:
y_bounce, y_bounce,
rgb_channel=-1, rgb_channel=-1,
alpha=alpha_value // alpha_div, alpha=alpha_value // alpha_div,
color_palette=sensor.PALETTE_IRONBOW, color_palette=image.PALETTE_IRONBOW,
hint=hint | image.CENTER, hint=hint | image.CENTER,
) )

View File

@ -81,7 +81,7 @@ while True:
y_bounce, y_bounce,
rgb_channel=-1, rgb_channel=-1,
alpha=alpha_value // alpha_div, alpha=alpha_value // alpha_div,
color_palette=sensor.PALETTE_IRONBOW, color_palette=image.PALETTE_IRONBOW,
alpha_palette=alpha_lut, alpha_palette=alpha_lut,
hint=hint | image.CENTER, hint=hint | image.CENTER,
) )

View File

@ -41,7 +41,7 @@ while True:
img = fir.snapshot( img = fir.snapshot(
x_size=w, x_size=w,
y_size=h, y_size=h,
color_palette=fir.PALETTE_IRONBOW, color_palette=image.PALETTE_IRONBOW,
hint=drawing_hint, hint=drawing_hint,
copy_to_fb=True, copy_to_fb=True,
) )

View File

@ -29,7 +29,7 @@ while True:
img = fir.snapshot( img = fir.snapshot(
x_size=w, x_size=w,
y_size=h, y_size=h,
color_palette=fir.PALETTE_IRONBOW, color_palette=image.PALETTE_IRONBOW,
hint=drawing_hint, hint=drawing_hint,
copy_to_fb=True, copy_to_fb=True,
) )

View File

@ -41,7 +41,7 @@ while True:
img = fir.snapshot( img = fir.snapshot(
x_size=w, x_size=w,
y_size=h, y_size=h,
color_palette=fir.PALETTE_IRONBOW, color_palette=image.PALETTE_IRONBOW,
hint=drawing_hint, hint=drawing_hint,
copy_to_fb=True, copy_to_fb=True,
) )

View File

@ -57,7 +57,7 @@ static const char fresh_main_py[] =
" x_scale = img.width() / fir_img.width()\n" " x_scale = img.width() / fir_img.width()\n"
" y_scale = img.height() / fir_img.height()\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" " 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" " alpha_palette = alpha_pal,\n"
" hint = image.BICUBIC)\n" " hint = image.BICUBIC)\n"
"\n" "\n"

View File

@ -1243,10 +1243,6 @@ STATIC const mp_rom_map_elem_t globals_dict_table[] = {
#if (OMV_ENABLE_FIR_LEPTON == 1) #if (OMV_ENABLE_FIR_LEPTON == 1)
{ MP_ROM_QSTR(MP_QSTR_FIR_LEPTON), MP_ROM_INT(FIR_LEPTON) }, { MP_ROM_QSTR(MP_QSTR_FIR_LEPTON), MP_ROM_INT(FIR_LEPTON) },
#endif #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_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_deinit), MP_ROM_PTR(&py_fir_deinit_obj) },
{ MP_ROM_QSTR(MP_QSTR_type), MP_ROM_PTR(&py_fir_type_obj) }, { MP_ROM_QSTR(MP_QSTR_type), MP_ROM_PTR(&py_fir_type_obj) },

View File

@ -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_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_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_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_AREA), MP_ROM_INT(IMAGE_HINT_AREA)},
{MP_ROM_QSTR(MP_QSTR_BILINEAR), MP_ROM_INT(IMAGE_HINT_BILINEAR)}, {MP_ROM_QSTR(MP_QSTR_BILINEAR), MP_ROM_INT(IMAGE_HINT_BILINEAR)},
{MP_ROM_QSTR(MP_QSTR_BICUBIC), MP_ROM_INT(IMAGE_HINT_BICUBIC)}, {MP_ROM_QSTR(MP_QSTR_BICUBIC), MP_ROM_INT(IMAGE_HINT_BICUBIC)},

View File

@ -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_WQXGA), MP_OBJ_NEW_SMALL_INT(FRAMESIZE_WQXGA)}, /* 2560x1600 */
{ MP_OBJ_NEW_QSTR(MP_QSTR_WQXGA2), MP_OBJ_NEW_SMALL_INT(FRAMESIZE_WQXGA2)}, /* 2592x1944 */ { 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 // 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_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)}, { MP_OBJ_NEW_QSTR(MP_QSTR_IOCTL_GET_READOUT_WINDOW), MP_OBJ_NEW_SMALL_INT(IOCTL_GET_READOUT_WINDOW)},