29 #include "../../opticflow/opticflow_calculator.h"
30 #include "generated/airframe.h"
35 #define MAX_AGENTS FAST9_MAX_CORNERS
36 #ifdef OPTICFLOW_CAMERA2
37 #define FAST9_MAX_CAMERAS 2
39 #define FAST9_MAX_CAMERAS 1
60 int gradient_method,
int camera_id)
77 min_gradient = (min_gradient == 0) ? 1 : min_gradient;
87 float GRID_ROWS = (int) ceil(sqrtf((
float)
n_agents));
88 float step_size_x = (img->
w - 2 * init_border) / (GRID_ROWS - 1);
89 float step_size_y = (img->
h - 2 * init_border) / (GRID_ROWS - 1);
93 for (
int c = 0; c < GRID_ROWS; c++) {
94 for (
int r = 0; r < GRID_ROWS; r++) {
98 px = ((float)(rand() % 10000) + 1) / 10000.0f;
99 py = ((float)(rand() % 10000) + 1) / 10000.0f;
100 pnorm = sqrtf(px * px + py * py);
101 struct agent_t ag = { (border + c * step_size_x), (border + r * step_size_y), 1, px / pnorm, py / pnorm};
102 agents[camera_id][a] = ag;
135 int gradient = (abs(dx) + abs(dy)) / 2;
136 if (abs(gradient) >= min_gradient) {
138 float norm_factor = sqrtf((
float)(dx * dx + dy * dy));
139 agents[camera_id][a].
x += (dy / norm_factor) * short_step;
140 agents[camera_id][a].
y += (dx / norm_factor) * short_step;
149 if (
agents[camera_id][a].
x > img->
w - border) {
150 agents[camera_id][a].
x = border;
151 }
else if (
agents[camera_id][a].
x < border) {
152 agents[camera_id][a].
x = img->
w - border;
154 if (
agents[camera_id][a].
y > img->
h - border) {
155 agents[camera_id][a].
y = border;
156 }
else if (
agents[camera_id][a].
y < border) {
157 agents[camera_id][a].
y = img->
h - border;
168 if (
agents[camera_id][a].active) {
179 if (!
agents[camera_id][a].active) {
struct agent_t agents[FAST9_MAX_CAMERAS][MAX_AGENTS]
#define FAST9_MAX_CAMERAS
void act_fast(struct image_t *img, uint8_t fast_threshold, uint16_t *num_corners, struct point_t **ret_corners, uint16_t n_agents, uint16_t n_time_steps, float long_step, float short_step, int min_gradient, int gradient_method, int camera_id)
Do an ACT-FAST corner detection.
Finds corners in an image by actively scanning the image.
int fast9_detect_pixel(struct image_t *img, uint8_t threshold, uint16_t x, uint16_t y)
Do a FAST9 corner detection for a single pixel.
void image_gradient_pixel(struct image_t *img, struct point_t *loc, int method, int *dx, int *dy)
Get the gradient at a pixel location.
Image helper functions like resizing, color filter, converters...
uint32_t x
The x coordinate of the point.
uint32_t y
The y coordinate of the point.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.