Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
qr_code.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015
3 *
4 * This file is part of Paparazzi.
5 *
6 * Paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * Paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
26#include "qr_code.h"
27#include "cv.h"
28
29#include "zbar.h"
30#include <stdio.h>
31
32#ifndef QRCODE_DRAW_RECTANGLE
33#define QRCODE_DRAW_RECTANGLE FALSE
34#endif
36
37#ifndef QRCODE_FPS
38#define QRCODE_FPS 0
39#endif
41
43{
44 // Add qrscan to the list of image processing tasks in video_thread
46}
47
48// Telemetry
50
51
53
54struct image_t *qrscan(struct image_t *img, uint8_t camera_id)
55{
56 int i, j;
57
58 // Create the JPEG encoded image
59 struct image_t gray;
61
62 uint8_t *ii = (uint8_t *) img->buf;
63 uint8_t *oi = (uint8_t *) gray.buf;
64
65 for (j = 0; j < img->h; j++) {
66 for (i = 0; i < img->w; i++) {
67 oi[j * img->w + i] = ii[(j * img->w + i) * 2 + 1];
68 }
69 }
70
71 if (scanner == 0) {
72 // create a reader
74
75 // configure the reader
76 //zbar_image_scanner_set_config(scanner, 0, ZBAR_CFG_POSITION, 1);
77 //zbar_increase_verbosity();
78 }
79
80 // wrap image data
82 zbar_image_set_format(image, *(int *)"Y800");
85
86 // scan the image for barcodes
88
89 if (n < 0) {
90 printf("zbar_scan_image returned %d\n", n);
91 }
92
93 // extract results
96 // do something useful with results
98 char *data = (char *)zbar_symbol_get_data(symbol);
99 printf("decoded %s symbol \"%s\" at %d %d\n",
101
104 struct point_t from;
105 struct point_t to;
106
108 // Determine where to draw from and to
110
113
116
117 // Draw a line between these two corners
118 image_draw_line(img, &to, &from);
119 }
120
121 }
122 // TODO: not allowed to access telemetry from vision thread
123#if DOWNLINK
125#endif
126 }
127
128// clean up
130 //zbar_image_scanner_destroy(scanner);
131
132 return img;
133}
struct video_listener * cv_add_to_device(struct video_config_t *device, cv_function func, uint16_t fps, uint8_t id)
Definition cv.c:46
Computer vision framework for onboard processing.
void image_draw_line(struct image_t *img, struct point_t *from, struct point_t *to)
Draw a pink line on the image.
Definition image.c:917
void image_create(struct image_t *img, uint16_t width, uint16_t height, enum image_type type)
Create a new image.
Definition image.c:43
uint32_t x
The x coordinate of the point.
Definition image.h:59
uint32_t y
The y coordinate of the point.
Definition image.h:60
@ IMAGE_GRAYSCALE
Grayscale image with only the Y part (uint8 per pixel)
Definition image.h:37
uint16_t foo
Definition main_demo5.c:58
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
#define QRCODE_DRAW_RECTANGLE
Definition qr_code.c:33
zbar_image_scanner_t * scanner
Definition qr_code.c:52
bool drawRectangleAroundQRCode
Definition qr_code.c:35
#define QRCODE_FPS
Default FPS (zero means run at camera fps)
Definition qr_code.c:38
void qrcode_init(void)
Definition qr_code.c:42
struct image_t * qrscan(struct image_t *img, uint8_t camera_id)
Definition qr_code.c:54
Parse video stream to detect and decode QR-codes using the ZBAR library.
Periodic telemetry system header (includes downlink utility and generated code).
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.