mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #954 from openmv/py_helper_update
Add default value to py_helper_keyword_object
This commit is contained in:
commit
37f8377aa1
@ -603,8 +603,7 @@ mp_obj_t py_fir_draw_ta(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
int alpha = py_helper_keyword_int(n_args, args, 2, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_alpha), 128);
|
||||
PY_ASSERT_TRUE_MSG((0 <= alpha) && (alpha <= 256), "Error: 0 <= alpha <= 256!");
|
||||
|
||||
mp_obj_t scale_obj = py_helper_keyword_object(n_args, args, 3, kw_args,
|
||||
MP_OBJ_NEW_QSTR(MP_QSTR_scale));
|
||||
mp_obj_t scale_obj = py_helper_keyword_object(n_args, args, 3, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_scale), NULL);
|
||||
if (scale_obj) {
|
||||
mp_obj_t *arg_scale;
|
||||
mp_obj_get_array_fixed_n(scale_obj, 2, &arg_scale);
|
||||
@ -674,8 +673,7 @@ mp_obj_t py_fir_draw_ir(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
int alpha = py_helper_keyword_int(n_args, args, 2, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_alpha), 128);
|
||||
PY_ASSERT_TRUE_MSG((0 <= alpha) && (alpha <= 256), "Error: 0 <= alpha <= 256!");
|
||||
|
||||
mp_obj_t scale_obj = py_helper_keyword_object(n_args, args, 3, kw_args,
|
||||
MP_OBJ_NEW_QSTR(MP_QSTR_scale));
|
||||
mp_obj_t scale_obj = py_helper_keyword_object(n_args, args, 3, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_scale), NULL);
|
||||
if (scale_obj) {
|
||||
mp_obj_t *arg_scale;
|
||||
mp_obj_get_array_fixed_n(scale_obj, 2, &arg_scale);
|
||||
@ -743,7 +741,7 @@ mp_obj_t py_fir_snapshot(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
int pixformat = py_helper_keyword_int(n_args, args, 2, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_pixformat), PIXFORMAT_RGB565);
|
||||
PY_ASSERT_TRUE_MSG((pixformat == PIXFORMAT_GRAYSCALE) || (pixformat == PIXFORMAT_RGB565), "Invalid Pixformat!");
|
||||
|
||||
mp_obj_t copy_to_fb_obj = py_helper_keyword_object(n_args, args, 3, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_copy_to_fb));
|
||||
mp_obj_t copy_to_fb_obj = py_helper_keyword_object(n_args, args, 3, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_copy_to_fb), NULL);
|
||||
bool copy_to_fb = false;
|
||||
image_t *arg_other = NULL;
|
||||
|
||||
|
||||
@ -370,7 +370,8 @@ int py_helper_ksize_to_n(int ksize)
|
||||
return ((ksize * 2) + 1) * ((ksize * 2) + 1);
|
||||
}
|
||||
|
||||
mp_obj_t py_helper_keyword_object(uint n_args, const mp_obj_t *args, uint arg_index, mp_map_t *kw_args, mp_obj_t kw)
|
||||
mp_obj_t py_helper_keyword_object(uint n_args, const mp_obj_t *args,
|
||||
uint arg_index, mp_map_t *kw_args, mp_obj_t kw, mp_obj_t default_val)
|
||||
{
|
||||
mp_map_elem_t *kw_arg = mp_map_lookup(kw_args, kw, MP_MAP_LOOKUP);
|
||||
|
||||
@ -379,7 +380,7 @@ mp_obj_t py_helper_keyword_object(uint n_args, const mp_obj_t *args, uint arg_in
|
||||
} else if (n_args > arg_index) {
|
||||
return args[arg_index];
|
||||
} else {
|
||||
return NULL;
|
||||
return default_val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +51,8 @@ void py_helper_keyword_thresholds(uint n_args, const mp_obj_t *args, uint arg_in
|
||||
mp_map_t *kw_args, list_t *thresholds);
|
||||
int py_helper_arg_to_ksize(const mp_obj_t arg);
|
||||
int py_helper_ksize_to_n(int ksize);
|
||||
mp_obj_t py_helper_keyword_object(uint n_args, const mp_obj_t *args, uint arg_index, mp_map_t *kw_args, mp_obj_t kw);
|
||||
mp_obj_t py_helper_keyword_object(uint n_args, const mp_obj_t *args,
|
||||
uint arg_index, mp_map_t *kw_args, mp_obj_t kw, mp_obj_t default_val);
|
||||
bool py_helper_is_equal_to_framebuffer(image_t *img);
|
||||
void py_helper_update_framebuffer(image_t *img);
|
||||
void py_helper_set_to_framebuffer(image_t *img);
|
||||
|
||||
@ -1437,7 +1437,8 @@ static mp_obj_t py_image_copy_int(uint n_args, const mp_obj_t *args, mp_map_t *k
|
||||
py_helper_keyword_float(n_args, args, 3, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_y_scale), 1.0f);
|
||||
PY_ASSERT_TRUE_MSG((0.0f <= arg_y_scale), "Error: 0.0 <= y_scale!");
|
||||
|
||||
mp_obj_t copy_to_fb_obj = py_helper_keyword_object(n_args, args, 4, kw_args, MP_OBJ_NEW_QSTR(mode ? MP_QSTR_copy : MP_QSTR_copy_to_fb));
|
||||
mp_obj_t copy_to_fb_obj = py_helper_keyword_object(n_args, args, 4, kw_args,
|
||||
MP_OBJ_NEW_QSTR(mode ? MP_QSTR_copy : MP_QSTR_copy_to_fb), NULL);
|
||||
bool copy_to_fb = false;
|
||||
image_t *arg_other = mode ? arg_img : NULL;
|
||||
|
||||
@ -4839,9 +4840,9 @@ static mp_obj_t py_image_find_blobs(uint n_args, const mp_obj_t *args, mp_map_t
|
||||
int margin =
|
||||
py_helper_keyword_int(n_args, args, 9, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_margin), 0);
|
||||
mp_obj_t threshold_cb =
|
||||
py_helper_keyword_object(n_args, args, 10, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_threshold_cb));
|
||||
py_helper_keyword_object(n_args, args, 10, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_threshold_cb), NULL);
|
||||
mp_obj_t merge_cb =
|
||||
py_helper_keyword_object(n_args, args, 11, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_merge_cb));
|
||||
py_helper_keyword_object(n_args, args, 11, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_merge_cb), NULL);
|
||||
unsigned int x_hist_bins_max =
|
||||
py_helper_keyword_int(n_args, args, 12, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_x_hist_bins_max), 0);
|
||||
unsigned int y_hist_bins_max =
|
||||
@ -6230,7 +6231,7 @@ static mp_obj_t py_image_find_edges(uint n_args, const mp_obj_t *args, mp_map_t
|
||||
py_helper_keyword_rectangle_roi(arg_img, n_args, args, 2, kw_args, &roi);
|
||||
|
||||
int thresh[2] = {100, 200};
|
||||
mp_obj_t thresh_obj = py_helper_keyword_object(n_args, args, 3, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_threshold));
|
||||
mp_obj_t thresh_obj = py_helper_keyword_object(n_args, args, 3, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_threshold), NULL);
|
||||
|
||||
if (thresh_obj) {
|
||||
mp_obj_t *thresh_array;
|
||||
@ -6722,7 +6723,7 @@ mp_obj_t py_imagereader_next_frame(uint n_args, const mp_obj_t *args, mp_map_t *
|
||||
{
|
||||
// Don't use the file buffer here...
|
||||
|
||||
mp_obj_t copy_to_fb_obj = py_helper_keyword_object(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_copy_to_fb));
|
||||
mp_obj_t copy_to_fb_obj = py_helper_keyword_object(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_copy_to_fb), NULL);
|
||||
bool copy_to_fb = true;
|
||||
image_t *arg_other = NULL;
|
||||
|
||||
@ -7106,7 +7107,8 @@ mp_obj_t py_image_load_image(uint n_args, const mp_obj_t *args, mp_map_t *kw_arg
|
||||
bool mode = mp_obj_is_integer(args[0]);
|
||||
const char *path = mode ? NULL : mp_obj_str_get_str(args[0]);
|
||||
|
||||
mp_obj_t copy_to_fb_obj = py_helper_keyword_object(n_args, args, mode ? 3 : 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_copy_to_fb));
|
||||
mp_obj_t copy_to_fb_obj = py_helper_keyword_object(n_args, args, mode ? 3 : 1,
|
||||
kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_copy_to_fb), NULL);
|
||||
bool copy_to_fb = false;
|
||||
image_t *arg_other = NULL;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user