Skip to content

Commit

Permalink
fixed drawing a line, now drawing around any qr code (#1716)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmeertens authored and flixr committed Jun 15, 2016
1 parent 514a74b commit 9d4106d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions sw/airborne/modules/computer_vision/lib/vision/image.c
Expand Up @@ -613,9 +613,9 @@ void image_draw_line(struct image_t *img, struct point_t *from, struct point_t *
line.
*/
int8_t incx, incy;
if (delta_x > 0) { incx = pixel_width; }
if (delta_x > 0) { incx = 1; }
else if (delta_x == 0) { incx = 0; }
else { incx = -pixel_width; }
else { incx = -1; }

if (delta_y > 0) { incy = 1; }
else if (delta_y == 0) { incy = 0; }
Expand Down
7 changes: 4 additions & 3 deletions sw/airborne/modules/computer_vision/qrcode/qr_code.c
Expand Up @@ -99,17 +99,18 @@ struct image_t *qrscan(struct image_t *img)
struct point_t from;
struct point_t to;

for (cornerIndex = 0; cornerIndex < 4; cornerIndex++) {
for (cornerIndex = 0; cornerIndex < zbar_symbol_get_loc_size(symbol); cornerIndex++) {
// Determine where to draw from and to
uint8_t nextCorner = (cornerIndex + 1) % 4;
uint8_t nextCorner = (cornerIndex + 1) % zbar_symbol_get_loc_size(symbol);

from.x = zbar_symbol_get_loc_x(symbol, cornerIndex);
from.y = zbar_symbol_get_loc_y(symbol, cornerIndex);

to.x = zbar_symbol_get_loc_x(symbol, nextCorner);
to.y = zbar_symbol_get_loc_y(symbol, nextCorner);

// Draw a line between these two corners
image_draw_line(img, &from, &to);
image_draw_line(img, &to, &from);
}

}
Expand Down

0 comments on commit 9d4106d

Please sign in to comment.