qrcode.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #include <zbar.h>
  9. typedef struct qr_reader qr_reader;
  10. typedef int qr_point[2];
  11. typedef struct qr_finder_line qr_finder_line;
  12. /*The number of bits of subpel precision to store image coordinates in.
  13. This helps when estimating positions in low-resolution images, which may have
  14. a module pitch only a pixel or two wide, making rounding errors matter a
  15. great deal.*/
  16. #define QR_FINDER_SUBPREC (2)
  17. /*A line crossing a finder pattern.
  18. Whether the line is horizontal or vertical is determined by context.
  19. The offsts to various parts of the finder pattern are as follows:
  20. |*****| |*****|*****|*****| |*****|
  21. |*****| |*****|*****|*****| |*****|
  22. ^ ^ ^ ^
  23. | | | |
  24. | | | pos[v]+len+eoffs
  25. | | pos[v]+len
  26. | pos[v]
  27. pos[v]-boffs
  28. Here v is 0 for horizontal and 1 for vertical lines.*/
  29. struct qr_finder_line {
  30. /*The location of the upper/left endpoint of the line.
  31. The left/upper edge of the center section is used, since other lines must
  32. cross in this region.*/
  33. qr_point pos;
  34. /*The length of the center section.
  35. This extends to the right/bottom of the center section, since other lines
  36. must cross in this region.*/
  37. int len;
  38. /*The offset to the midpoint of the upper/left section (part of the outside
  39. ring), or 0 if we couldn't identify the edge of the beginning section.
  40. We use the midpoint instead of the edge because it can be located more
  41. reliably.*/
  42. int boffs;
  43. /*The offset to the midpoint of the end section (part of the outside ring),
  44. or 0 if we couldn't identify the edge of the end section.
  45. We use the midpoint instead of the edge because it can be located more
  46. reliably.*/
  47. int eoffs;
  48. };
  49. qr_reader *_zbar_qr_create(void);
  50. void _zbar_qr_destroy(qr_reader *reader);
  51. void _zbar_qr_reset(qr_reader *reader);
  52. int _zbar_qr_found_line(qr_reader *reader,
  53. int direction,
  54. const qr_finder_line *line);
  55. int _zbar_qr_decode(qr_reader *reader,
  56. zbar_image_scanner_t *iscn,
  57. zbar_image_t *img);
  58. #endif