1 /*Copyright (C) 2008-2009 Timothy B. Terriberry (tterribe@xiph.org) 2 You can redistribute this library and/or modify it under the terms of the 3 GNU Lesser General Public License as published by the Free Software 4 Foundation; either version 2.1 of the License, or (at your option) any later 5 version.*/ 6 #ifndef _QRCODE_H_ 7 #define _QRCODE_H_ 8 9 #include <zbar.h> 10 11 typedef struct qr_reader qr_reader; 12 13 typedef int qr_point[2]; 14 typedef struct qr_finder_line qr_finder_line; 15 16 /*The number of bits of subpel precision to store image coordinates in. 17 This helps when estimating positions in low-resolution images, which may have 18 a module pitch only a pixel or two wide, making rounding errors matter a 19 great deal.*/ 20 #define QR_FINDER_SUBPREC (2) 21 22 /*A line crossing a finder pattern. 23 Whether the line is horizontal or vertical is determined by context. 24 The offsts to various parts of the finder pattern are as follows: 25 |*****| |*****|*****|*****| |*****| 26 |*****| |*****|*****|*****| |*****| 27 ^ ^ ^ ^ 28 | | | | 29 | | | pos[v]+len+eoffs 30 | | pos[v]+len 31 | pos[v] 32 pos[v]-boffs 33 Here v is 0 for horizontal and 1 for vertical lines.*/ 34 struct qr_finder_line { 35 /*The location of the upper/left endpoint of the line. 36 The left/upper edge of the center section is used, since other lines must 37 cross in this region.*/ 38 qr_point pos; 39 /*The length of the center section. 40 This extends to the right/bottom of the center section, since other lines 41 must cross in this region.*/ 42 int len; 43 /*The offset to the midpoint of the upper/left section (part of the outside 44 ring), or 0 if we couldn't identify the edge of the beginning section. 45 We use the midpoint instead of the edge because it can be located more 46 reliably.*/ 47 int boffs; 48 /*The offset to the midpoint of the end section (part of the outside ring), 49 or 0 if we couldn't identify the edge of the end section. 50 We use the midpoint instead of the edge because it can be located more 51 reliably.*/ 52 int eoffs; 53 }; 54 55 qr_reader *_zbar_qr_create(void); 56 void _zbar_qr_destroy(qr_reader *reader); 57 void _zbar_qr_reset(qr_reader *reader); 58 59 int _zbar_qr_found_line(qr_reader *reader, 60 int direction, 61 const qr_finder_line *line); 62 int _zbar_qr_decode(qr_reader *reader, 63 zbar_image_scanner_t *iscn, 64 unsigned width, unsigned height, const unsigned char *data); 65 66 #endif 67