mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Use default roi when calling save_image
This commit is contained in:
parent
2ac623ad1a
commit
4c63721efa
@ -52,18 +52,9 @@ int imlib_load_image(image_t *image, const char *path)
|
||||
return ppm_read(image, path);
|
||||
}
|
||||
|
||||
int imlib_save_image(image_t *image, const char *path, rectangle_t *r)
|
||||
int imlib_save_image(image_t *image, const char *path, rectangle_t *roi)
|
||||
{
|
||||
if (r == NULL) {
|
||||
rectangle_t rectangle;
|
||||
rectangle.x = 0;
|
||||
rectangle.y = 0;
|
||||
rectangle.w = image->w;
|
||||
rectangle.h = image->h;
|
||||
return ppm_write_subimg(image, path, &rectangle);
|
||||
} else {
|
||||
return ppm_write_subimg(image, path, r);
|
||||
}
|
||||
return ppm_write_subimg(image, path, roi);
|
||||
}
|
||||
|
||||
void imlib_draw_line(image_t *img, int x0, int y0, int x1, int y1, int c)
|
||||
|
||||
@ -299,7 +299,7 @@ int bmp_read_pixels(FIL *fp, image_t *img, int line_start, int line_end);
|
||||
int bmp_read(image_t *img, const char *path);
|
||||
int bmp_write_subimg(image_t *img, const char *path, rectangle_t *r);
|
||||
int imlib_load_image(image_t *image, const char *path);
|
||||
int imlib_save_image(image_t *image, const char *path, rectangle_t *r);
|
||||
int imlib_save_image(image_t *image, const char *path, rectangle_t *roi);
|
||||
|
||||
/* Rectangle functions */
|
||||
rectangle_t *rectangle_alloc(int16_t x, int16_t y, int16_t w, int16_t h);
|
||||
|
||||
@ -666,26 +666,13 @@ static mp_obj_t py_image_difference(mp_obj_t img_obj, mp_obj_t other_obj)
|
||||
static mp_obj_t py_image_save(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
int res;
|
||||
rectangle_t roi;
|
||||
image_t *image = py_image_cobj(args[0]);
|
||||
const char *path = mp_obj_str_get_str(args[1]);
|
||||
|
||||
mp_map_elem_t *kw_subimage = mp_map_lookup(kw_args, MP_OBJ_NEW_QSTR(qstr_from_str("subimage")), MP_MAP_LOOKUP);
|
||||
if (kw_subimage != NULL) {
|
||||
mp_obj_t *array;
|
||||
mp_obj_get_array_fixed_n(kw_subimage->value, 4, &array);
|
||||
|
||||
rectangle_t r = {
|
||||
mp_obj_get_int(array[0]),
|
||||
mp_obj_get_int(array[1]),
|
||||
mp_obj_get_int(array[2]),
|
||||
mp_obj_get_int(array[3]),
|
||||
};
|
||||
|
||||
res = imlib_save_image(image, path, &r);
|
||||
} else {
|
||||
res = imlib_save_image(image, path, NULL);
|
||||
}
|
||||
get_rectangle_kw(kw_args, MP_OBJ_NEW_QSTR(qstr_from_str("subimage")), &roi);
|
||||
|
||||
res = imlib_save_image(image, path, &roi);
|
||||
if (res != FR_OK) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, ffs_strerror(res)));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user