Skip to content

Commit 3ca9229

Browse files
committed
Fix threshrold to return tuple
Fixes #32
1 parent 8f16324 commit 3ca9229

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/imgproc.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,13 +2127,18 @@ mp_obj_t cv2_imgproc_threshold(size_t n_args, const mp_obj_t *pos_args, mp_map_t
21272127
int type = args[ARG_type].u_int;
21282128
Mat dst = mp_obj_to_mat(args[ARG_dst].u_obj);
21292129

2130+
mp_float_t retval;
2131+
21302132
// Call the corresponding OpenCV function
21312133
try {
2132-
threshold(src, dst, thresh, maxval, type);
2134+
retval = threshold(src, dst, thresh, maxval, type);
21332135
} catch(Exception& e) {
21342136
mp_raise_msg(&mp_type_Exception, MP_ERROR_TEXT(e.what()));
21352137
}
21362138

2137-
// Return the result
2138-
return mat_to_mp_obj(dst);
2139+
// Return the result as a tuple
2140+
mp_obj_t result_tuple[2];
2141+
result_tuple[0] = mp_obj_new_float(retval);
2142+
result_tuple[1] = mat_to_mp_obj(dst);
2143+
return mp_obj_new_tuple(2, result_tuple);
21392144
}

0 commit comments

Comments
 (0)