44 float distance_1, distance_2;
54 }
else if (count >= max_samples) {
60 for (i = 0; i <
count; i++) {
61 for (j = i + 1; j <
count; j++) {
63 dx = (float)vectors[i].pos.x - (
float)vectors[j].
pos.
x;
64 dy = (float)vectors[i].pos.y - (
float)vectors[j].
pos.
y;
65 distance_1 = sqrtf(dx * dx + dy * dy);
67 if (distance_1 < 1
E-5) {
72 dx = (float)vectors[i].pos.x + (
float)vectors[i].
flow_x - (float)vectors[j].pos.x - (
float)vectors[j].
flow_x;
73 dy = (float)vectors[i].pos.y + (
float)vectors[i].
flow_y - (float)vectors[j].pos.y - (
float)vectors[j].
flow_y;
74 distance_2 = sqrtf(dx * dx + dy * dy);
76 divs_sum += (distance_2 - distance_1) / distance_1;
92 dx = (float)vectors[i].pos.x - (
float)vectors[j].
pos.
x;
93 dy = (float)vectors[i].pos.y - (
float)vectors[j].
pos.
y;
94 distance_1 = sqrtf(dx * dx + dy * dy);
96 if (distance_1 < 1
E-5) {
101 dx = (float)vectors[i].pos.x + (
float)vectors[i].
flow_x - (float)vectors[j].pos.x - (
float)vectors[j].
flow_x;
102 dy = (float)vectors[i].pos.y + (
float)vectors[i].
flow_y - (float)vectors[j].pos.y - (
float)vectors[j].
flow_y;
103 distance_2 = sqrtf(dx * dx + dy * dy);
105 divs_sum += (distance_2 - distance_1) / distance_1;
110 if (used_samples < 1){
115 return divs_sum / used_samples;
int32_t flow_y
The y direction flow in subpixels.
Calculate divergence from flow vectors by looking at line sizes beteween the points.
uint32_t x
The x coordinate of the point.
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.
struct point_t pos
The original position the flow comes from in subpixels.
uint32_t y
The y coordinate of the point.
uint16_t count
Number of times the point has been tracked successfully.
int32_t flow_x
The x direction flow in subpixels.