From ba80759f61af006a700ee1390ec574bb84726848 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Wed, 30 Dec 2020 00:32:22 +0200 Subject: [PATCH] Fix reference to ffs_strerror when image I/O is disabled. --- src/omv/imlib/haar.c | 2 +- src/omv/modules/py_image.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/omv/imlib/haar.c b/src/omv/imlib/haar.c index f6577f7b2..51b3cf45b 100644 --- a/src/omv/imlib/haar.c +++ b/src/omv/imlib/haar.c @@ -285,7 +285,7 @@ int imlib_load_cascade(cascade_t *cascade, const char *path) // xml cascade return imlib_load_cascade_from_file(cascade, path); #else - nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Image I/O is not supported")); + return -1; #endif } diff --git a/src/omv/modules/py_image.c b/src/omv/modules/py_image.c index b244cab94..5cf486730 100644 --- a/src/omv/modules/py_image.c +++ b/src/omv/modules/py_image.c @@ -35,7 +35,9 @@ static const mp_obj_type_t py_cascade_type; static const mp_obj_type_t py_image_type; +#if defined(IMLIB_ENABLE_IMAGE_IO) extern const char *ffs_strerror(FRESULT res); +#endif // Haar Cascade /////////////////////////////////////////////////////////////// @@ -7231,7 +7233,13 @@ mp_obj_t py_image_load_cascade(uint n_args, const mp_obj_t *args, mp_map_t *kw_a // Load cascade from file or flash int res = imlib_load_cascade(&cascade, path); if (res != FR_OK) { + #if defined(IMLIB_ENABLE_IMAGE_IO) + // cascade is not built-in and failed to load it from file. nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, ffs_strerror(res))); + #else + // cascade is not built-in. + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Image I/O is not supported")); + #endif } // Read the number of stages