From a75b2e82f0bfbdad078713f5bf0e26b14eee0319 Mon Sep 17 00:00:00 2001 From: Titus Date: Thu, 23 Mar 2017 15:28:38 +0100 Subject: [PATCH] in void calculate_edge_histogram, 1)IMPORTANT: corrected the index used for img_buf, the +1 caused a out of array memory address to be looked up. Also it caused wrong calculations to take place arround the borders of the image 2)removed comments that were from an old version --- .../modules/computer_vision/lib/vision/edge_flow.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sw/airborne/modules/computer_vision/lib/vision/edge_flow.c b/sw/airborne/modules/computer_vision/lib/vision/edge_flow.c index 681e09c7c11..7921190cd32 100644 --- a/sw/airborne/modules/computer_vision/lib/vision/edge_flow.c +++ b/sw/airborne/modules/computer_vision/lib/vision/edge_flow.c @@ -122,9 +122,9 @@ void calculate_edge_histogram(struct image_t *img, int32_t edge_histogram[], sobel_sum = 0; for (c = -1; c <= 1; c++) { - idx = interlace * (image_width * y + (x + c)); // 2 for interlace + idx = interlace * (image_width * y + (x + c)); - sobel_sum += Sobel[c + 1] * (int32_t)img_buf[idx + 1]; + sobel_sum += Sobel[c + 1] * (int32_t)img_buf[idx]; } sobel_sum = abs(sobel_sum); if (sobel_sum > edge_threshold) { @@ -141,9 +141,9 @@ void calculate_edge_histogram(struct image_t *img, int32_t edge_histogram[], sobel_sum = 0; for (c = -1; c <= 1; c++) { - idx = interlace * (image_width * (y + c) + x); // 2 for interlace + idx = interlace * (image_width * (y + c) + x); - sobel_sum += Sobel[c + 1] * (int32_t)img_buf[idx + 1]; + sobel_sum += Sobel[c + 1] * (int32_t)img_buf[idx]; } sobel_sum = abs(sobel_sum); if (sobel_sum > edge_threshold) {