Skip to content

Commit

Permalink
scale flow quality more restrictive
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophTobler authored and jlecoeur committed Sep 18, 2017
1 parent cebbc4b commit 398e9c3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/modules/flow/flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,15 +525,15 @@ uint8_t compute_flow(uint8_t *image1, uint8_t *image2, float x_rate, float y_rat
if (used[block_id])
{
if (FLOAT_AS_BOOL(global_data.param[PARAM_USB_DRAW_FLOW]))
{
{
// Draw optic flow vector
uint8_t steps = fmax(abs(dirsx[used_block_id]), abs(dirsy[used_block_id]));
for (int8_t k = 0; k < steps; k++)
{
// Draw black segment to represent optic flow vector
int8_t dx = (k * dirsx[used_block_id]) / steps;
int8_t dy = (k * dirsy[used_block_id]) / steps;
image1[(j + dy) * ((uint16_t) global_data.param[PARAM_IMAGE_WIDTH]) + i + dx] = 0;
image1[(j + dy) * ((uint16_t) global_data.param[PARAM_IMAGE_WIDTH]) + i + dx] = 0;
}
}

Expand Down Expand Up @@ -680,9 +680,9 @@ uint8_t compute_flow(uint8_t *image1, uint8_t *image2, float x_rate, float y_rat
float subdirx = 0.0f;
if (subdirs[h] == 0 || subdirs[h] == 1 || subdirs[h] == 7) subdirx = 0.5f;
if (subdirs[h] == 3 || subdirs[h] == 4 || subdirs[h] == 5) subdirx = -0.5f;
float flow_x = (float)dirsx[h] + subdirx;
float flow_x = (float)dirsx[h] + subdirx;
histflowx_sum += flow_x;
histflowx_sum2 += flow_x * flow_x;
histflowx_sum2 += flow_x * flow_x;
meancount_x++;

float subdiry = 0.0f;
Expand Down Expand Up @@ -788,10 +788,10 @@ uint8_t compute_flow(uint8_t *image1, uint8_t *image2, float x_rate, float y_rat

/* calc quality from ratio of used & unused blocks*/
uint8_t qual = (uint8_t)(meancount * 255 / (NUM_BLOCKS*NUM_BLOCKS));
/* Adapt quality based on standard deviation of flow in used blocks */

/* Adapt quality based on standard deviation of flow in used blocks */
float stddev = sqrtf(stddev_flowx * stddev_flowx + stddev_flowy * stddev_flowy);
float qual_scaling = fmaxf(0.0f, (SEARCH_SIZE - stddev) / SEARCH_SIZE);
float qual_scaling = fmaxf(0.0f, (SEARCH_SIZE - 2.0f*stddev) / SEARCH_SIZE);
qual *= qual_scaling;

return qual;
Expand Down

0 comments on commit 398e9c3

Please sign in to comment.