Skip to content

Commit 4cf886d

Browse files
committed
Remove min() and max()
These already exist in ulab numpy as minimum() and maximum(). Removing helps keep the firmware a bit smaller without losing any functionality.
1 parent 6590714 commit 4cf886d

File tree

3 files changed

+0
-64
lines changed

3 files changed

+0
-64
lines changed

src/core.cpp

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -41,61 +41,3 @@ mp_obj_t cv2_core_inRange(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_
4141
// Return the result
4242
return mat_to_mp_obj(dst);
4343
}
44-
45-
mp_obj_t cv2_core_max(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
46-
// Define the arguments
47-
enum { ARG_src1, ARG_src2, ARG_dst };
48-
static const mp_arg_t allowed_args[] = {
49-
{ MP_QSTR_src1, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = MP_OBJ_NULL } },
50-
{ MP_QSTR_src2, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = MP_OBJ_NULL } },
51-
{ MP_QSTR_dst, MP_ARG_OBJ, { .u_obj = mp_const_none } },
52-
};
53-
54-
// Parse the arguments
55-
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
56-
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
57-
58-
// Convert arguments to required types
59-
Mat src1 = mp_obj_to_mat(args[ARG_src1].u_obj);
60-
Mat src2 = mp_obj_to_mat(args[ARG_src2].u_obj);
61-
Mat dst = mp_obj_to_mat(args[ARG_dst].u_obj);
62-
63-
// Call the corresponding OpenCV function
64-
try {
65-
max(src1, src2, dst);
66-
} catch(Exception& e) {
67-
mp_raise_msg(&mp_type_Exception, MP_ERROR_TEXT(e.what()));
68-
}
69-
70-
// Return the result
71-
return mat_to_mp_obj(dst);
72-
}
73-
74-
mp_obj_t cv2_core_min(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
75-
// Define the arguments
76-
enum { ARG_src1, ARG_src2, ARG_dst };
77-
static const mp_arg_t allowed_args[] = {
78-
{ MP_QSTR_src1, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = MP_OBJ_NULL } },
79-
{ MP_QSTR_src2, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = MP_OBJ_NULL } },
80-
{ MP_QSTR_dst, MP_ARG_OBJ, { .u_obj = mp_const_none } },
81-
};
82-
83-
// Parse the arguments
84-
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
85-
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
86-
87-
// Convert arguments to required types
88-
Mat src1 = mp_obj_to_mat(args[ARG_src1].u_obj);
89-
Mat src2 = mp_obj_to_mat(args[ARG_src2].u_obj);
90-
Mat dst = mp_obj_to_mat(args[ARG_dst].u_obj);
91-
92-
// Call the corresponding OpenCV function
93-
try {
94-
min(src1, src2, dst);
95-
} catch(Exception& e) {
96-
mp_raise_msg(&mp_type_Exception, MP_ERROR_TEXT(e.what()));
97-
}
98-
99-
// Return the result
100-
return mat_to_mp_obj(dst);
101-
}

src/core.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,3 @@
22
#include "py/runtime.h"
33

44
extern mp_obj_t cv2_core_inRange(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
5-
extern mp_obj_t cv2_core_max(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
6-
extern mp_obj_t cv2_core_min(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);

src/opencv_upy.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
// OpenCV core module
99
static MP_DEFINE_CONST_FUN_OBJ_KW(cv2_core_inRange_obj, 3, cv2_core_inRange);
10-
static MP_DEFINE_CONST_FUN_OBJ_KW(cv2_core_max_obj, 2, cv2_core_max);
11-
static MP_DEFINE_CONST_FUN_OBJ_KW(cv2_core_min_obj, 2, cv2_core_min);
1210

1311
// OpenCV imgproc module
1412
static MP_DEFINE_CONST_FUN_OBJ_KW(cv2_imgproc_arrowedLine_obj, 4, cv2_imgproc_arrowedLine);
@@ -153,8 +151,6 @@ static const mp_rom_map_elem_t cv2_module_globals_table[] = {
153151
////////////////////////////////////////////////////////////////////////////
154152

155153
{ MP_ROM_QSTR(MP_QSTR_inRange), MP_ROM_PTR(&cv2_core_inRange_obj) },
156-
{ MP_ROM_QSTR(MP_QSTR_max), MP_ROM_PTR(&cv2_core_max_obj) },
157-
{ MP_ROM_QSTR(MP_QSTR_min), MP_ROM_PTR(&cv2_core_min_obj) },
158154

159155
////////////////////////////////////////////////////////////////////////////
160156
// OpenCV imgproc functions

0 commit comments

Comments
 (0)