mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Remove angle from keypoint.
* Not really used right now and saves 4 bytes per keypoint.
This commit is contained in:
parent
3a747ef952
commit
4d7db778fb
@ -198,7 +198,7 @@ const static uint8_t DESCRIPTION_PAIRS[512][2] = {
|
|||||||
|
|
||||||
|
|
||||||
// simply take average on a square patch, not even gaussian approx
|
// simply take average on a square patch, not even gaussian approx
|
||||||
static uint8_t mean_intensity(image_t *image, i_image_t *i_image, int kp_x, int kp_y, uint32_t rot, uint32_t point)
|
static int mean_intensity(image_t *image, i_image_t *i_image, int kp_x, int kp_y, uint32_t rot, uint32_t point)
|
||||||
{
|
{
|
||||||
int pidx = (point/6)%8;
|
int pidx = (point/6)%8;
|
||||||
float alpha, beta, theta = 0;
|
float alpha, beta, theta = 0;
|
||||||
@ -266,7 +266,7 @@ array_t *freak_find_keypoints(image_t *image, bool normalized, int threshold, re
|
|||||||
fast_detect(image, keypoints, threshold, roi);
|
fast_detect(image, keypoints, threshold, roi);
|
||||||
|
|
||||||
if (array_length(keypoints)) {
|
if (array_length(keypoints)) {
|
||||||
// compute integral image
|
// Compute integral image
|
||||||
imlib_integral_image_alloc(&i_image, image->w, image->h);
|
imlib_integral_image_alloc(&i_image, image->w, image->h);
|
||||||
imlib_integral_image(image, &i_image);
|
imlib_integral_image(image, &i_image);
|
||||||
|
|
||||||
@ -276,7 +276,6 @@ array_t *freak_find_keypoints(image_t *image, bool normalized, int threshold, re
|
|||||||
// Estimate orientation (gradient)
|
// Estimate orientation (gradient)
|
||||||
if (normalized) {
|
if (normalized) {
|
||||||
thetaIdx = 0; // Assign 0° to all kpts
|
thetaIdx = 0; // Assign 0° to all kpts
|
||||||
kpt->angle = 0.0f;
|
|
||||||
} else {
|
} else {
|
||||||
// Get the points intensity value in the un-rotated pattern
|
// Get the points intensity value in the un-rotated pattern
|
||||||
for (int i=kNB_POINTS; i--;) {
|
for (int i=kNB_POINTS; i--;) {
|
||||||
@ -294,12 +293,14 @@ array_t *freak_find_keypoints(image_t *image, bool normalized, int threshold, re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Estimate orientation
|
// Estimate orientation
|
||||||
kpt->angle = fast_atan2f((float)direction1, (float)direction0) * (180.0f/PI);
|
float angle = fast_atan2f((float)direction1, (float)direction0) * (180.0f/PI);
|
||||||
thetaIdx = (int)(kNB_ORIENTATION * kpt->angle * (1.0f/360.0f) + 0.5f);
|
thetaIdx = (int)(kNB_ORIENTATION * angle * (1.0f/360.0f) + 0.5f);
|
||||||
|
|
||||||
if (thetaIdx < 0) {
|
if (thetaIdx < 0) {
|
||||||
thetaIdx += kNB_ORIENTATION;
|
thetaIdx += kNB_ORIENTATION;
|
||||||
} else if (thetaIdx >= kNB_ORIENTATION) {
|
}
|
||||||
|
|
||||||
|
if (thetaIdx >= kNB_ORIENTATION) {
|
||||||
thetaIdx -= kNB_ORIENTATION;
|
thetaIdx -= kNB_ORIENTATION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -408,12 +409,6 @@ int freak_save_descriptor(array_t *kpts, const char *path)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write angle
|
|
||||||
res = f_write(&fp, &kp->angle, sizeof(kp->angle), &bytes);
|
|
||||||
if (res != FR_OK || bytes != sizeof(kp->angle)) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write descriptor
|
// Write descriptor
|
||||||
res = f_write(&fp, kp->desc, KPT_DESC_SIZE, &bytes);
|
res = f_write(&fp, kp->desc, KPT_DESC_SIZE, &bytes);
|
||||||
if (res != FR_OK || bytes != KPT_DESC_SIZE) {
|
if (res != FR_OK || bytes != KPT_DESC_SIZE) {
|
||||||
@ -461,12 +456,6 @@ int freak_load_descriptor(array_t *kpts, const char *path)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read angle
|
|
||||||
res = f_read(&fp, &kp->angle, sizeof(kp->angle), &bytes);
|
|
||||||
if (res != FR_OK || bytes != sizeof(kp->angle)) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read descriptor
|
// Read descriptor
|
||||||
res = f_read(&fp, kp->desc, KPT_DESC_SIZE, &bytes);
|
res = f_read(&fp, kp->desc, KPT_DESC_SIZE, &bytes);
|
||||||
if (res != FR_OK || bytes != KPT_DESC_SIZE) {
|
if (res != FR_OK || bytes != KPT_DESC_SIZE) {
|
||||||
|
|||||||
@ -248,7 +248,6 @@ typedef struct cluster {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t x;
|
uint16_t x;
|
||||||
uint16_t y;
|
uint16_t y;
|
||||||
float angle;
|
|
||||||
uint8_t desc[64];
|
uint8_t desc[64];
|
||||||
} kp_t;
|
} kp_t;
|
||||||
|
|
||||||
|
|||||||
@ -354,9 +354,6 @@ static mp_obj_t py_image_draw_keypoints(uint n_args, const mp_obj_t *args, mp_ma
|
|||||||
|
|
||||||
for (int i=0; i<array_length(kpts_obj->kpts); i++) {
|
for (int i=0; i<array_length(kpts_obj->kpts); i++) {
|
||||||
kp_t *kp = array_at(kpts_obj->kpts, i);
|
kp_t *kp = array_at(kpts_obj->kpts, i);
|
||||||
float co = arm_cos_f32(kp->angle);
|
|
||||||
float si = arm_sin_f32(kp->angle);
|
|
||||||
imlib_draw_line(arg_img, kp->x, kp->y, kp->x+(co*arg_s), kp->y+(si*arg_s), arg_c);
|
|
||||||
imlib_draw_circle(arg_img, kp->x, kp->y, (arg_s-2)/2, arg_c);
|
imlib_draw_circle(arg_img, kp->x, kp->y, (arg_s-2)/2, arg_c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user