52 float mean_divergence;
62 n_elements = (count * count - count) / 2;
63 divs = (
float *) malloc(
sizeof(
float) * n_elements);
67 for (i = 0; i < count; i++) {
68 for (j = i + 1; j < count; j++) {
70 dx = vectors[i].
pos.
x - vectors[j].
pos.
x;
71 dy = vectors[i].
pos.
y - vectors[j].
pos.
y;
72 distance_1 = sqrt(dx * dx + dy * dy);
77 distance_2 = sqrt(dx * dx + dy * dy);
80 divs[sample] = (distance_2 - distance_1) / distance_1;
86 mean_divergence =
get_mean(divs, n_elements);
92 divs = (
float *) malloc(
sizeof(
float) * n_samples);
95 for (sample = 0; sample < n_samples; sample++) {
105 dx = vectors[i].
pos.
x - vectors[j].
pos.
x;
106 dy = vectors[i].
pos.
y - vectors[j].
pos.
y;
107 distance_1 = sqrt(dx * dx + dy * dy);
112 distance_2 = sqrt(dx * dx + dy * dy);
115 divs[sample] = (distance_2 - distance_1) / distance_1;
119 mean_divergence =
get_mean(divs, n_samples);
126 return mean_divergence;
139 for (i = 0; i < n_elements; i++) {
float get_mean(float *numbers, int n_elements)
Get the sample mean of a vector of floats.
uint16_t x
The x coordinate of the point.
Calculate divergence from flow vectors by looking at line sizes beteween the points.
float get_size_divergence(struct flow_t *vectors, int count, int n_samples)
Get divergence from optical flow vectors based on line sizes between corners.
int16_t flow_x
The x direction flow in subpixels.
struct point_t pos
The original position the flow comes from.
uint16_t y
The y coordinate of the point.
int16_t flow_y
The y direction flow in subpixels.