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) {