Add keypoints detector arg.

This commit is contained in:
iabdalkader 2017-01-08 18:40:28 +02:00
parent 05ea5115b5
commit 6b7eb1a105
4 changed files with 13 additions and 5 deletions

View File

@ -1035,7 +1035,8 @@ void fast_detect(image_t *image, array_t *keypoints, int threshold, rectangle_t
void agast_detect(image_t *image, array_t *keypoints, int threshold, rectangle_t *roi);
/* ORB descriptor */
array_t *orb_find_keypoints(image_t *image, bool normalized, int threshold, float scale_factor, int max_keypoints, rectangle_t *roi);
array_t *orb_find_keypoints(image_t *image, bool normalized, int threshold,
float scale_factor, int max_keypoints, corner_detector_t corner_detector, rectangle_t *roi);
int orb_match_keypoints(array_t *kpts1, array_t *kpts2, int threshold, rectangle_t *r, point_t *c);
int orb_filter_keypoints(array_t *kpts, rectangle_t *r, point_t *c);
int orb_save_descriptor(FIL *fp, array_t *kpts);

View File

@ -348,7 +348,8 @@ static void image_scale(image_t *src, image_t *dst)
}
}
array_t *orb_find_keypoints(image_t *img, bool normalized, int threshold, float scale_factor, int max_keypoints, rectangle_t *roi)
array_t *orb_find_keypoints(image_t *img, bool normalized, int threshold,
float scale_factor, int max_keypoints, corner_detector_t corner_detector, rectangle_t *roi)
{
array_t *kpts;
array_alloc(&kpts, xfree);
@ -395,7 +396,11 @@ array_t *orb_find_keypoints(image_t *img, bool normalized, int threshold, float
array_alloc(&kpts_octave, NULL);
// Find kpts
agast_detect(&img_scaled, kpts_octave, threshold, &roi_scaled);
if (corner_detector == CORNER_FAST) {
fast_detect(&img_scaled, kpts_octave, threshold, &roi_scaled);
} else {
agast_detect(&img_scaled, kpts_octave, threshold, &roi_scaled);
}
for (int k=0; k<array_length(kpts_octave); k++) {
// Set keypoint octave/scale

View File

@ -2226,9 +2226,10 @@ static mp_obj_t py_image_find_keypoints(uint n_args, const mp_obj_t *args, mp_ma
bool normalized = py_helper_lookup_int(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_normalized), false);
float scale_factor = py_helper_lookup_float(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_scale_factor), 1.5f);
int max_keypoints = py_helper_lookup_float(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_max_keypoints), 200);
corner_detector_t corner_detector = py_helper_lookup_float(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_corner_detector), CORNER_AGAST);
// Find keypoints
array_t *kpts = orb_find_keypoints(arg_img, normalized, threshold, scale_factor, max_keypoints, &roi);
array_t *kpts = orb_find_keypoints(arg_img, normalized, threshold, scale_factor, max_keypoints, corner_detector, &roi);
if (array_length(kpts)) {
py_kp_obj_t *kp_obj = m_new_obj(py_kp_obj_t);
@ -2753,7 +2754,7 @@ int py_image_descriptor_from_roi(image_t *img, const char *path, rectangle_t *ro
FRESULT res = FR_OK;
printf("Save Descriptor: ROI(%d %d %d %d)\n", roi->x, roi->y, roi->w, roi->h);
array_t *kpts = orb_find_keypoints(img, false, 20, 1.5f, 200, roi);
array_t *kpts = orb_find_keypoints(img, false, 20, 1.5f, 200, CORNER_AGAST, roi);
printf("Save Descriptor: KPTS(%d)\n", array_length(kpts));
if (array_length(kpts)) {

View File

@ -99,6 +99,7 @@ Q(lens_corr)
Q(filter_outliers)
Q(scale_factor)
Q(max_keypoints)
Q(corner_detector)
// Lcd Module
Q(lcd)