mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #301 from kwagyeman/master
Fixed bugs with logpolar/linpolar.
This commit is contained in:
commit
601d1593cf
@ -31,10 +31,10 @@ void imlib_logpolar_int(image_t *dst, image_t *src, rectangle_t *roi, bool linea
|
||||
sourceX = fast_roundf((alt_fast_exp(rho, linear) * cos_table[theta]) + w_2);
|
||||
sourceY = fast_roundf((alt_fast_exp(rho, linear) * sin_table[theta]) + h_2);
|
||||
} else {
|
||||
int x_2 = x - w_2;
|
||||
int y_2 = y - h_2;
|
||||
float x_2 = x - w_2;
|
||||
float y_2 = y - h_2;
|
||||
float rho = alt_fast_log(fast_sqrtf((x_2 * x_2) + (y_2 * y_2)), linear);
|
||||
float theta = 630 - (x_2 ? (fast_atan2f(y_2, x_2) * (180 / M_PI)) : ((y_2 < 0) ? 270 : 90));
|
||||
int theta = 630 - (x_2 ? fast_roundf(fast_atan2f(y_2, x_2) * (180 / M_PI)) : ((y_2 < 0) ? 270 : 90));
|
||||
if (theta >= 360) theta -= 360;
|
||||
sourceX = fast_roundf(theta * theta_scale_inv);
|
||||
sourceY = fast_roundf(rho * rho_scale_inv);
|
||||
@ -62,10 +62,10 @@ void imlib_logpolar_int(image_t *dst, image_t *src, rectangle_t *roi, bool linea
|
||||
sourceX = fast_roundf((alt_fast_exp(rho, linear) * cos_table[theta]) + w_2);
|
||||
sourceY = fast_roundf((alt_fast_exp(rho, linear) * sin_table[theta]) + h_2);
|
||||
} else {
|
||||
int x_2 = x - w_2;
|
||||
int y_2 = y - h_2;
|
||||
float x_2 = x - w_2;
|
||||
float y_2 = y - h_2;
|
||||
float rho = alt_fast_log(fast_sqrtf((x_2 * x_2) + (y_2 * y_2)), linear);
|
||||
float theta = 630 - (x_2 ? (fast_atan2f(y_2, x_2) * (180 / M_PI)) : ((y_2 < 0) ? 270 : 90));
|
||||
int theta = 630 - (x_2 ? fast_roundf(fast_atan2f(y_2, x_2) * (180 / M_PI)) : ((y_2 < 0) ? 270 : 90));
|
||||
if (theta >= 360) theta -= 360;
|
||||
sourceX = fast_roundf(theta * theta_scale_inv);
|
||||
sourceY = fast_roundf(rho * rho_scale_inv);
|
||||
@ -93,13 +93,13 @@ void imlib_logpolar_int(image_t *dst, image_t *src, rectangle_t *roi, bool linea
|
||||
sourceX = fast_roundf((alt_fast_exp(rho, linear) * cos_table[theta]) + w_2);
|
||||
sourceY = fast_roundf((alt_fast_exp(rho, linear) * sin_table[theta]) + h_2);
|
||||
} else {
|
||||
int x_2 = x - w_2;
|
||||
int y_2 = y - h_2;
|
||||
float x_2 = x - w_2;
|
||||
float y_2 = y - h_2;
|
||||
float rho = alt_fast_log(fast_sqrtf((x_2 * x_2) + (y_2 * y_2)), linear);
|
||||
float theta = 630 - (x_2 ? (fast_atan2f(y_2, x_2) * (180 / M_PI)) : ((y_2 < 0) ? 270 : 90));
|
||||
int theta = 630 - (x_2 ? fast_roundf(fast_atan2f(y_2, x_2) * (180 / M_PI)) : ((y_2 < 0) ? 270 : 90));
|
||||
if (theta >= 360) theta -= 360;
|
||||
sourceX = fast_roundf(theta * theta_scale_inv);
|
||||
sourceY = fast_roundf(rho * rho_scale_inv);
|
||||
sourceX = IM_MIN(IM_MAX(fast_roundf(theta * theta_scale_inv), 0), (roi->w-1));
|
||||
sourceY = IM_MIN(IM_MAX(fast_roundf(rho * rho_scale_inv), 0), (roi->h-1));
|
||||
}
|
||||
|
||||
if ((0 <= sourceX) && (sourceX < roi->w) && (0 <= sourceY) && (sourceY < roi->h)) {
|
||||
|
||||
@ -1287,7 +1287,8 @@ static mp_obj_t py_image_linpolar(uint n_args, const mp_obj_t *args, mp_map_t *k
|
||||
{
|
||||
image_t *arg_img = py_image_cobj(args[0]);
|
||||
PY_ASSERT_TRUE_MSG(IM_IS_RGB565(arg_img), "Image format is not supported.");
|
||||
bool reverse = py_helper_lookup_int(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_reverse), false);
|
||||
bool reverse = py_helper_lookup_int(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_reverse),
|
||||
(n_args > 1) ? mp_obj_get_int(args[1]) : false);
|
||||
|
||||
fb_alloc_mark();
|
||||
imlib_logpolar(arg_img, true, reverse);
|
||||
@ -1299,7 +1300,8 @@ static mp_obj_t py_image_logpolar(uint n_args, const mp_obj_t *args, mp_map_t *k
|
||||
{
|
||||
image_t *arg_img = py_image_cobj(args[0]);
|
||||
PY_ASSERT_TRUE_MSG(IM_IS_RGB565(arg_img), "Image format is not supported.");
|
||||
bool reverse = py_helper_lookup_int(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_reverse), false);
|
||||
bool reverse = py_helper_lookup_int(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_reverse),
|
||||
(n_args > 1) ? mp_obj_get_int(args[1]) : false);
|
||||
|
||||
fb_alloc_mark();
|
||||
imlib_logpolar(arg_img, false, reverse);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user