diff --git a/src/omv/img/freak.c b/src/omv/img/freak.c index b9c7c0516..7eacda218 100644 --- a/src/omv/img/freak.c +++ b/src/omv/img/freak.c @@ -69,6 +69,7 @@ #define SCALE_FACTOR (1.0f) // SCALE_STEP ^ SCALE_IDX #define PATTERN_SCALE (22) +#define MAX_KP_DIST (512) // number of points on each concentric circle (from outer to inner) const static int n[8] = {6,6,6,6,6,6,6,1}; @@ -311,7 +312,7 @@ int16_t *freak_match_keypoints(kp_t *kpts1, int kpts1_size, kp_t *kpts2, int kpt for (int x=0; x t) { + if ((((MAX_KP_DIST-min_dist)*100/MAX_KP_DIST)) < t) { //no match kpts_match[x] = -1; } else { diff --git a/src/omv/py/py_image.c b/src/omv/py/py_image.c index e434b2a79..bcb50962c 100644 --- a/src/omv/py/py_image.c +++ b/src/omv/py/py_image.c @@ -1110,9 +1110,10 @@ static mp_obj_t py_image_match_keypoints(uint n_args, const mp_obj_t *args) py_kp_obj_t *kpts1 = ((py_kp_obj_t*)args[1]); py_kp_obj_t *kpts2 = ((py_kp_obj_t*)args[2]); - // sanity checks + // Sanity checks PY_ASSERT_TYPE(kpts1, &py_kp_type); PY_ASSERT_TYPE(kpts2, &py_kp_type); + PY_ASSERT_TRUE_MSG((threshold >=0 && threshold <= 100), "Expected threshold between 0 and 100"); if (kpts1->size == 0 || kpts2->size == 0) { return mp_const_none;