mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 22:17:01 +08:00
Added corner method as a setting (detail)
This commit is contained in:
@@ -43,6 +43,8 @@
|
|||||||
<define name="MAX_ITERATIONS" value="10" description="Maximum number of iterations the Lucas Kanade algorithm should take"/>
|
<define name="MAX_ITERATIONS" value="10" description="Maximum number of iterations the Lucas Kanade algorithm should take"/>
|
||||||
<define name="THRESHOLD_VEC" value="2" description="TThreshold in subpixels when the iterations of Lucas Kanade should stop"/>
|
<define name="THRESHOLD_VEC" value="2" description="TThreshold in subpixels when the iterations of Lucas Kanade should stop"/>
|
||||||
|
|
||||||
|
<define name="CORNER_METHOD" value="1" description="Method used to look for corners, exhaustive FAST (0) or ACT-FAST (1)."/>
|
||||||
|
|
||||||
<!-- FAST9 corner detection parameters -->
|
<!-- FAST9 corner detection parameters -->
|
||||||
<define name="FAST9_ADAPTIVE" value="TRUE" description="Whether we should use and adapative FAST9 crner detection threshold"/>
|
<define name="FAST9_ADAPTIVE" value="TRUE" description="Whether we should use and adapative FAST9 crner detection threshold"/>
|
||||||
<define name="FAST9_THRESHOLD" value="20" description="FAST9 default threshold"/>
|
<define name="FAST9_THRESHOLD" value="20" description="FAST9 default threshold"/>
|
||||||
@@ -65,6 +67,7 @@
|
|||||||
<!-- Optical flow calculations parameters -->
|
<!-- Optical flow calculations parameters -->
|
||||||
<dl_settings name="vision_calc">
|
<dl_settings name="vision_calc">
|
||||||
<dl_setting var="opticflow.method" min="0" step="1" max="1" module="computer_vision/opticflow_module" shortname="method" values="LK_Fast9|EdgeFlow" param="METHOD"/>
|
<dl_setting var="opticflow.method" min="0" step="1" max="1" module="computer_vision/opticflow_module" shortname="method" values="LK_Fast9|EdgeFlow" param="METHOD"/>
|
||||||
|
<dl_setting var="opticflow.corner_method" min="0" step="1" max="1" module="computer_vision/opticflow_module" shortname="corner_method" values="exhaustive-FAST|ACT-FAST" param="CORNER_METHOD"/>
|
||||||
<dl_setting var="opticflow.window_size" module="computer_vision/opticflow_module" min="0" step="1" max="20" shortname="window_size" param="OPTICFLOW_WINDOW_SIZE"/>
|
<dl_setting var="opticflow.window_size" module="computer_vision/opticflow_module" min="0" step="1" max="20" shortname="window_size" param="OPTICFLOW_WINDOW_SIZE"/>
|
||||||
<dl_setting var="opticflow.search_distance" module="computer_vision/opticflow_module" min="0" step="1" max="50" shortname="search_distance" param="SEARCH_DISTANCE"/>
|
<dl_setting var="opticflow.search_distance" module="computer_vision/opticflow_module" min="0" step="1" max="50" shortname="search_distance" param="SEARCH_DISTANCE"/>
|
||||||
<dl_setting var="opticflow.subpixel_factor" module="computer_vision/opticflow_module" min="0" step="10" max="1000" shortname="subpixel_factor" param="OPTICFLOW_SUBPIXEL_FACTOR"/>
|
<dl_setting var="opticflow.subpixel_factor" module="computer_vision/opticflow_module" min="0" step="10" max="1000" shortname="subpixel_factor" param="OPTICFLOW_SUBPIXEL_FACTOR"/>
|
||||||
@@ -89,7 +92,7 @@
|
|||||||
<dl_setting var="opticflow.actfast_long_step" module="computer_vision/opticflow_module" min="1" step="1" max="100" shortname="actfast_long_step" param="OPTICFLOW_ACTFAST_LONG_STEP"/>
|
<dl_setting var="opticflow.actfast_long_step" module="computer_vision/opticflow_module" min="1" step="1" max="100" shortname="actfast_long_step" param="OPTICFLOW_ACTFAST_LONG_STEP"/>
|
||||||
<dl_setting var="opticflow.actfast_short_step" module="computer_vision/opticflow_module" min="1" step="1" max="10" shortname="actfast_short_step" param="OPTICFLOW_ACTFAST_SHORT_STEP"/>
|
<dl_setting var="opticflow.actfast_short_step" module="computer_vision/opticflow_module" min="1" step="1" max="10" shortname="actfast_short_step" param="OPTICFLOW_ACTFAST_SHORT_STEP"/>
|
||||||
<dl_setting var="opticflow.actfast_min_gradient" module="computer_vision/opticflow_module" min="1" step="1" max="255" shortname="actfast_min_gradient" param="OPTICFLOW_ACTFAST_MIN_GRADIENT"/>
|
<dl_setting var="opticflow.actfast_min_gradient" module="computer_vision/opticflow_module" min="1" step="1" max="255" shortname="actfast_min_gradient" param="OPTICFLOW_ACTFAST_MIN_GRADIENT"/>
|
||||||
<dl_setting var="opticflow.actfast_gradient_method" module="computer_vision/opticflow_module" min="1" step="1" max="1" values="SIMPLE|SOBEL" shortname="actfast_gradient_method" param="OPTICFLOW_ACTFAST_GRADIENT_METHOD"/>
|
<dl_setting var="opticflow.actfast_gradient_method" module="computer_vision/opticflow_module" min="0" step="1" max="1" values="SIMPLE|SOBEL" shortname="actfast_gradient_method" param="OPTICFLOW_ACTFAST_GRADIENT_METHOD"/>
|
||||||
|
|
||||||
<!-- Changes pyramid level of lucas kanade optical flow. -->
|
<!-- Changes pyramid level of lucas kanade optical flow. -->
|
||||||
<dl_setting var="opticflow.pyramid_level" module="computer_vision/opticflow_module" min="0" step="1" max="10" shortname="pyramid_level" param="OPTICFLOW_PYRAMID_LEVEL"/>
|
<dl_setting var="opticflow.pyramid_level" module="computer_vision/opticflow_module" min="0" step="1" max="10" shortname="pyramid_level" param="OPTICFLOW_PYRAMID_LEVEL"/>
|
||||||
|
|||||||
@@ -51,10 +51,9 @@
|
|||||||
|
|
||||||
#define EXHAUSTIVE_FAST 0
|
#define EXHAUSTIVE_FAST 0
|
||||||
#define ACT_FAST 1
|
#define ACT_FAST 1
|
||||||
|
// TODO: these are now adapted, but perhaps later could be a setting:
|
||||||
uint16_t n_time_steps = 10;
|
uint16_t n_time_steps = 10;
|
||||||
uint16_t n_agents = 25;
|
uint16_t n_agents = 25;
|
||||||
// corner method:
|
|
||||||
#define CORNER_METHOD 0
|
|
||||||
|
|
||||||
// What methods are run to determine divergence, lateral flow, etc.
|
// What methods are run to determine divergence, lateral flow, etc.
|
||||||
// SIZE_DIV looks at line sizes and only calculates divergence
|
// SIZE_DIV looks at line sizes and only calculates divergence
|
||||||
@@ -63,6 +62,12 @@ uint16_t n_agents = 25;
|
|||||||
// relative velocities in x, y, z (divergence / time to contact), the slope of the surface, and the surface roughness.
|
// relative velocities in x, y, z (divergence / time to contact), the slope of the surface, and the surface roughness.
|
||||||
#define LINEAR_FIT 1
|
#define LINEAR_FIT 1
|
||||||
|
|
||||||
|
#ifndef OPTICFLOW_CORNER_METHOD
|
||||||
|
// This can be estimated by total possible image height / total Field of view
|
||||||
|
#define OPTICFLOW_CORNER_METHOD ACT_FAST
|
||||||
|
#endif
|
||||||
|
PRINT_CONFIG_VAR(OPTICFLOW_CORNER_METHOD)
|
||||||
|
|
||||||
// Camera parameters (defaults are from an ARDrone 2)
|
// Camera parameters (defaults are from an ARDrone 2)
|
||||||
#ifndef OPTICFLOW_FOV_W
|
#ifndef OPTICFLOW_FOV_W
|
||||||
#define OPTICFLOW_FOV_W 0.89360857702
|
#define OPTICFLOW_FOV_W 0.89360857702
|
||||||
@@ -273,7 +278,7 @@ void opticflow_calc_init(struct opticflow_t *opticflow)
|
|||||||
opticflow->fast9_rsize = 512;
|
opticflow->fast9_rsize = 512;
|
||||||
opticflow->fast9_ret_corners = calloc(opticflow->fast9_rsize, sizeof(struct point_t));
|
opticflow->fast9_ret_corners = calloc(opticflow->fast9_rsize, sizeof(struct point_t));
|
||||||
|
|
||||||
|
opticflow->corner_method = OPTICFLOW_CORNER_METHOD;
|
||||||
opticflow->actfast_long_step = OPTICFLOW_ACTFAST_LONG_STEP;
|
opticflow->actfast_long_step = OPTICFLOW_ACTFAST_LONG_STEP;
|
||||||
opticflow->actfast_short_step = OPTICFLOW_ACTFAST_SHORT_STEP;
|
opticflow->actfast_short_step = OPTICFLOW_ACTFAST_SHORT_STEP;
|
||||||
opticflow->actfast_min_gradient = OPTICFLOW_ACTFAST_MIN_GRADIENT;
|
opticflow->actfast_min_gradient = OPTICFLOW_ACTFAST_MIN_GRADIENT;
|
||||||
@@ -342,7 +347,7 @@ bool calc_fast9_lukas_kanade(struct opticflow_t *opticflow, struct image_t *img,
|
|||||||
// needs to be set to 0 because result is now static
|
// needs to be set to 0 because result is now static
|
||||||
result->corner_cnt = 0;
|
result->corner_cnt = 0;
|
||||||
|
|
||||||
if (CORNER_METHOD == EXHAUSTIVE_FAST) {
|
if (opticflow->corner_method == EXHAUSTIVE_FAST) {
|
||||||
// FAST corner detection
|
// FAST corner detection
|
||||||
// TODO: There is something wrong with fast9_detect destabilizing FPS. This problem is reduced with putting min_distance
|
// TODO: There is something wrong with fast9_detect destabilizing FPS. This problem is reduced with putting min_distance
|
||||||
// to 0 (see defines), however a more permanent solution should be considered
|
// to 0 (see defines), however a more permanent solution should be considered
|
||||||
@@ -352,7 +357,7 @@ bool calc_fast9_lukas_kanade(struct opticflow_t *opticflow, struct image_t *img,
|
|||||||
&opticflow->fast9_ret_corners,
|
&opticflow->fast9_ret_corners,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
} else if (CORNER_METHOD == ACT_FAST) {
|
} else if (opticflow->corner_method == ACT_FAST) {
|
||||||
// ACT-FAST corner detection:
|
// ACT-FAST corner detection:
|
||||||
act_fast(&opticflow->prev_img_gray, opticflow->fast9_threshold, &result->corner_cnt,
|
act_fast(&opticflow->prev_img_gray, opticflow->fast9_threshold, &result->corner_cnt,
|
||||||
&opticflow->fast9_ret_corners, n_agents, n_time_steps,
|
&opticflow->fast9_ret_corners, n_agents, n_time_steps,
|
||||||
@@ -371,14 +376,14 @@ bool calc_fast9_lukas_kanade(struct opticflow_t *opticflow, struct image_t *img,
|
|||||||
opticflow->fast9_threshold--;
|
opticflow->fast9_threshold--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CORNER_METHOD == ACT_FAST) {
|
if (opticflow->corner_method == ACT_FAST) {
|
||||||
n_time_steps++;
|
n_time_steps++;
|
||||||
n_agents++;
|
n_agents++;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (result->corner_cnt > OPTICFLOW_MAX_TRACK_CORNERS * 2 && opticflow->fast9_threshold < FAST9_HIGH_THRESHOLD) {
|
} else if (result->corner_cnt > OPTICFLOW_MAX_TRACK_CORNERS * 2 && opticflow->fast9_threshold < FAST9_HIGH_THRESHOLD) {
|
||||||
opticflow->fast9_threshold++;
|
opticflow->fast9_threshold++;
|
||||||
if (CORNER_METHOD == ACT_FAST && n_time_steps > 5 && n_agents > 10) {
|
if (opticflow->corner_method == ACT_FAST && n_time_steps > 5 && n_agents > 10) {
|
||||||
n_time_steps--;
|
n_time_steps--;
|
||||||
n_agents--;
|
n_agents--;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ struct opticflow_t {
|
|||||||
struct image_t prev_img_gray; ///< Previous gray image frame
|
struct image_t prev_img_gray; ///< Previous gray image frame
|
||||||
|
|
||||||
uint8_t method; ///< Method to use to calculate the optical flow
|
uint8_t method; ///< Method to use to calculate the optical flow
|
||||||
|
uint8_t corner_method; ///< Method to use for determining where the corners are
|
||||||
uint16_t window_size; ///< Window size for the blockmatching algorithm (general value for all methods)
|
uint16_t window_size; ///< Window size for the blockmatching algorithm (general value for all methods)
|
||||||
uint16_t search_distance; ///< Search distance for blockmatching alg.
|
uint16_t search_distance; ///< Search distance for blockmatching alg.
|
||||||
bool derotation; ///< Derotation switched on or off (depended on the quality of the gyroscope measurement)
|
bool derotation; ///< Derotation switched on or off (depended on the quality of the gyroscope measurement)
|
||||||
|
|||||||
Reference in New Issue
Block a user