29 #include "../../opticflow/opticflow_calculator.h"
34 #define MAX_AGENTS FAST9_MAX_CORNERS
35 #ifndef OPTICFLOW_CAMERA2
56 int gradient_method,
int camera_id)
68 min_gradient = (min_gradient == 0) ? 1 : min_gradient;
78 float GRID_ROWS = (int) ceil(sqrtf((
float)
n_agents));
79 float step_size_x = (img->
w - 2 * init_border) / (GRID_ROWS - 1);
80 float step_size_y = (img->
h - 2 * init_border) / (GRID_ROWS - 1);
84 for (
int c = 0; c < GRID_ROWS; c++) {
85 for (
int r = 0; r < GRID_ROWS; r++) {
89 px = ((float)(rand() % 10000) + 1) / 10000.0f;
90 py = ((float)(rand() % 10000) + 1) / 10000.0f;
91 pnorm = sqrtf(px * px + py * py);
92 struct agent_t ag = { (border + c * step_size_x), (border + r * step_size_y), 1, px / pnorm, py / pnorm};
126 int gradient = (abs(dx) + abs(dy)) / 2;
127 if (abs(gradient) >= min_gradient) {
129 float norm_factor = sqrtf((
float)(dx * dx + dy * dy));
130 agents[camera_id][a].
x += (dy / norm_factor) * short_step;
131 agents[camera_id][a].
y += (dx / norm_factor) * short_step;
140 if (
agents[camera_id][a].
x > img->
w - border) {
141 agents[camera_id][a].
x = border;
142 }
else if (
agents[camera_id][a].
x < border) {
143 agents[camera_id][a].
x = img->
w - border;
145 if (
agents[camera_id][a].
y > img->
h - border) {
146 agents[camera_id][a].
y = border;
147 }
else if (
agents[camera_id][a].
y < border) {
148 agents[camera_id][a].
y = img->
h - border;
159 if (
agents[camera_id][a].active) {
170 if (!
agents[camera_id][a].active) {
struct agent_t agents[1][MAX_AGENTS]
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.