ZBar bar code reader . http://zbar.sourceforge.net/ ZBar is licensed under the GNU LGPL 2.1 to enable development of both open source and commercial projects.

Dependents:   GR-PEACH_Camera_in_barcode levkov_ov7670

LICENSE

The ZBar Bar Code Reader is Copyright (C) 2007-2009 Jeff Brown <spadix@users.sourceforge.net> The QR Code reader is Copyright (C) 1999-2009 Timothy B. Terriberry <tterribe@xiph.org>

You can redistribute this library and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

ISAAC is based on the public domain implementation by Robert J. Jenkins Jr., and is itself public domain.

Portions of the bit stream reader are copyright (C) The Xiph.Org Foundation 1994-2008, and are licensed under a BSD-style license.

The Reed-Solomon decoder is derived from an implementation (C) 1991-1995 Henry Minsky (hqm@ua.com, hqm@ai.mit.edu), and is licensed under the LGPL with permission.

Committer:
RyoheiHagimoto
Date:
Tue Apr 19 02:19:39 2016 +0000
Revision:
1:500d42699c34
Parent:
0:56c5742b9e2b
Add copying.txt and license.txt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RyoheiHagimoto 0:56c5742b9e2b 1 /*Copyright (C) 2008-2009 Timothy B. Terriberry (tterribe@xiph.org)
RyoheiHagimoto 0:56c5742b9e2b 2 You can redistribute this library and/or modify it under the terms of the
RyoheiHagimoto 0:56c5742b9e2b 3 GNU Lesser General Public License as published by the Free Software
RyoheiHagimoto 0:56c5742b9e2b 4 Foundation; either version 2.1 of the License, or (at your option) any later
RyoheiHagimoto 0:56c5742b9e2b 5 version.*/
RyoheiHagimoto 0:56c5742b9e2b 6 #if !defined(_qrdec_H)
RyoheiHagimoto 0:56c5742b9e2b 7 # define _qrdec_H (1)
RyoheiHagimoto 0:56c5742b9e2b 8
RyoheiHagimoto 0:56c5742b9e2b 9 #include <zbar.h>
RyoheiHagimoto 0:56c5742b9e2b 10
RyoheiHagimoto 0:56c5742b9e2b 11 typedef struct qr_code_data_entry qr_code_data_entry;
RyoheiHagimoto 0:56c5742b9e2b 12 typedef struct qr_code_data qr_code_data;
RyoheiHagimoto 0:56c5742b9e2b 13 typedef struct qr_code_data_list qr_code_data_list;
RyoheiHagimoto 0:56c5742b9e2b 14
RyoheiHagimoto 0:56c5742b9e2b 15 typedef enum qr_mode{
RyoheiHagimoto 0:56c5742b9e2b 16 /*Numeric digits ('0'...'9').*/
RyoheiHagimoto 0:56c5742b9e2b 17 QR_MODE_NUM=1,
RyoheiHagimoto 0:56c5742b9e2b 18 /*Alphanumeric characters ('0'...'9', 'A'...'Z', plus the punctuation
RyoheiHagimoto 0:56c5742b9e2b 19 ' ', '$', '%', '*', '+', '-', '.', '/', ':').*/
RyoheiHagimoto 0:56c5742b9e2b 20 QR_MODE_ALNUM,
RyoheiHagimoto 0:56c5742b9e2b 21 /*Structured-append header.*/
RyoheiHagimoto 0:56c5742b9e2b 22 QR_MODE_STRUCT,
RyoheiHagimoto 0:56c5742b9e2b 23 /*Raw 8-bit bytes.*/
RyoheiHagimoto 0:56c5742b9e2b 24 QR_MODE_BYTE,
RyoheiHagimoto 0:56c5742b9e2b 25 /*FNC1 marker (for more info, see http://www.mecsw.com/specs/uccean128.html).
RyoheiHagimoto 0:56c5742b9e2b 26 In the "first position" data is formatted in accordance with GS1 General
RyoheiHagimoto 0:56c5742b9e2b 27 Specifications.*/
RyoheiHagimoto 0:56c5742b9e2b 28 QR_MODE_FNC1_1ST,
RyoheiHagimoto 0:56c5742b9e2b 29 /*Mode 6 reserved?*/
RyoheiHagimoto 0:56c5742b9e2b 30 /*Extended Channel Interpretation code.*/
RyoheiHagimoto 0:56c5742b9e2b 31 QR_MODE_ECI=7,
RyoheiHagimoto 0:56c5742b9e2b 32 /*SJIS kanji characters.*/
RyoheiHagimoto 0:56c5742b9e2b 33 QR_MODE_KANJI,
RyoheiHagimoto 0:56c5742b9e2b 34 /*FNC1 marker (for more info, see http://www.mecsw.com/specs/uccean128.html).
RyoheiHagimoto 0:56c5742b9e2b 35 In the "second position" data is formatted in accordance with an industry
RyoheiHagimoto 0:56c5742b9e2b 36 application as specified by AIM Inc.*/
RyoheiHagimoto 0:56c5742b9e2b 37 QR_MODE_FNC1_2ND
RyoheiHagimoto 0:56c5742b9e2b 38 }qr_mode;
RyoheiHagimoto 0:56c5742b9e2b 39
RyoheiHagimoto 0:56c5742b9e2b 40 /*Check if a mode has a data buffer associated with it.
RyoheiHagimoto 0:56c5742b9e2b 41 Currently this is only modes with exactly one bit set.*/
RyoheiHagimoto 0:56c5742b9e2b 42 #define QR_MODE_HAS_DATA(_mode) (!((_mode)&(_mode)-1))
RyoheiHagimoto 0:56c5742b9e2b 43
RyoheiHagimoto 0:56c5742b9e2b 44 /*ECI may be used to signal a character encoding for the data.*/
RyoheiHagimoto 0:56c5742b9e2b 45 typedef enum qr_eci_encoding{
RyoheiHagimoto 0:56c5742b9e2b 46 /*GLI0 is like CP437, but the encoding is reset at the beginning of each
RyoheiHagimoto 0:56c5742b9e2b 47 structured append symbol.*/
RyoheiHagimoto 0:56c5742b9e2b 48 QR_ECI_GLI0,
RyoheiHagimoto 0:56c5742b9e2b 49 /*GLI1 is like ISO8859_1, but the encoding is reset at the beginning of each
RyoheiHagimoto 0:56c5742b9e2b 50 structured append symbol.*/
RyoheiHagimoto 0:56c5742b9e2b 51 QR_ECI_GLI1,
RyoheiHagimoto 0:56c5742b9e2b 52 /*The remaining encodings do not reset at the start of the next structured
RyoheiHagimoto 0:56c5742b9e2b 53 append symbol.*/
RyoheiHagimoto 0:56c5742b9e2b 54 QR_ECI_CP437,
RyoheiHagimoto 0:56c5742b9e2b 55 /*Western European.*/
RyoheiHagimoto 0:56c5742b9e2b 56 QR_ECI_ISO8859_1,
RyoheiHagimoto 0:56c5742b9e2b 57 /*Central European.*/
RyoheiHagimoto 0:56c5742b9e2b 58 QR_ECI_ISO8859_2,
RyoheiHagimoto 0:56c5742b9e2b 59 /*South European.*/
RyoheiHagimoto 0:56c5742b9e2b 60 QR_ECI_ISO8859_3,
RyoheiHagimoto 0:56c5742b9e2b 61 /*North European.*/
RyoheiHagimoto 0:56c5742b9e2b 62 QR_ECI_ISO8859_4,
RyoheiHagimoto 0:56c5742b9e2b 63 /*Cyrillic.*/
RyoheiHagimoto 0:56c5742b9e2b 64 QR_ECI_ISO8859_5,
RyoheiHagimoto 0:56c5742b9e2b 65 /*Arabic.*/
RyoheiHagimoto 0:56c5742b9e2b 66 QR_ECI_ISO8859_6,
RyoheiHagimoto 0:56c5742b9e2b 67 /*Greek.*/
RyoheiHagimoto 0:56c5742b9e2b 68 QR_ECI_ISO8859_7,
RyoheiHagimoto 0:56c5742b9e2b 69 /*Hebrew.*/
RyoheiHagimoto 0:56c5742b9e2b 70 QR_ECI_ISO8859_8,
RyoheiHagimoto 0:56c5742b9e2b 71 /*Turkish.*/
RyoheiHagimoto 0:56c5742b9e2b 72 QR_ECI_ISO8859_9,
RyoheiHagimoto 0:56c5742b9e2b 73 /*Nordic.*/
RyoheiHagimoto 0:56c5742b9e2b 74 QR_ECI_ISO8859_10,
RyoheiHagimoto 0:56c5742b9e2b 75 /*Thai.*/
RyoheiHagimoto 0:56c5742b9e2b 76 QR_ECI_ISO8859_11,
RyoheiHagimoto 0:56c5742b9e2b 77 /*There is no ISO/IEC 8859-12.*/
RyoheiHagimoto 0:56c5742b9e2b 78 /*Baltic rim.*/
RyoheiHagimoto 0:56c5742b9e2b 79 QR_ECI_ISO8859_13=QR_ECI_ISO8859_11+2,
RyoheiHagimoto 0:56c5742b9e2b 80 /*Celtic.*/
RyoheiHagimoto 0:56c5742b9e2b 81 QR_ECI_ISO8859_14,
RyoheiHagimoto 0:56c5742b9e2b 82 /*Western European with euro.*/
RyoheiHagimoto 0:56c5742b9e2b 83 QR_ECI_ISO8859_15,
RyoheiHagimoto 0:56c5742b9e2b 84 /*South-Eastern European (with euro).*/
RyoheiHagimoto 0:56c5742b9e2b 85 QR_ECI_ISO8859_16,
RyoheiHagimoto 0:56c5742b9e2b 86 /*ECI 000019 is reserved?*/
RyoheiHagimoto 0:56c5742b9e2b 87 /*Shift-JIS.*/
RyoheiHagimoto 0:56c5742b9e2b 88 QR_ECI_SJIS=20
RyoheiHagimoto 0:56c5742b9e2b 89 }qr_eci_encoding;
RyoheiHagimoto 0:56c5742b9e2b 90
RyoheiHagimoto 0:56c5742b9e2b 91
RyoheiHagimoto 0:56c5742b9e2b 92 /*A single unit of parsed QR code data.*/
RyoheiHagimoto 0:56c5742b9e2b 93 struct qr_code_data_entry{
RyoheiHagimoto 0:56c5742b9e2b 94 /*The mode of this data block.*/
RyoheiHagimoto 0:56c5742b9e2b 95 qr_mode mode;
RyoheiHagimoto 0:56c5742b9e2b 96 union{
RyoheiHagimoto 0:56c5742b9e2b 97 /*Data buffer for modes that have one.*/
RyoheiHagimoto 0:56c5742b9e2b 98 struct{
RyoheiHagimoto 0:56c5742b9e2b 99 unsigned char *buf;
RyoheiHagimoto 0:56c5742b9e2b 100 int len;
RyoheiHagimoto 0:56c5742b9e2b 101 }data;
RyoheiHagimoto 0:56c5742b9e2b 102 /*Decoded "Extended Channel Interpretation" data.*/
RyoheiHagimoto 0:56c5742b9e2b 103 unsigned eci;
RyoheiHagimoto 0:56c5742b9e2b 104 /*Structured-append header data.*/
RyoheiHagimoto 0:56c5742b9e2b 105 struct{
RyoheiHagimoto 0:56c5742b9e2b 106 unsigned char sa_index;
RyoheiHagimoto 0:56c5742b9e2b 107 unsigned char sa_size;
RyoheiHagimoto 0:56c5742b9e2b 108 unsigned char sa_parity;
RyoheiHagimoto 0:56c5742b9e2b 109 }sa;
RyoheiHagimoto 0:56c5742b9e2b 110 }payload;
RyoheiHagimoto 0:56c5742b9e2b 111 };
RyoheiHagimoto 0:56c5742b9e2b 112
RyoheiHagimoto 0:56c5742b9e2b 113
RyoheiHagimoto 0:56c5742b9e2b 114
RyoheiHagimoto 0:56c5742b9e2b 115 /*Low-level QR code data.*/
RyoheiHagimoto 0:56c5742b9e2b 116 struct qr_code_data{
RyoheiHagimoto 0:56c5742b9e2b 117 /*The decoded data entries.*/
RyoheiHagimoto 0:56c5742b9e2b 118 qr_code_data_entry *entries;
RyoheiHagimoto 0:56c5742b9e2b 119 int nentries;
RyoheiHagimoto 0:56c5742b9e2b 120 /*The code version (1...40).*/
RyoheiHagimoto 0:56c5742b9e2b 121 unsigned char version;
RyoheiHagimoto 0:56c5742b9e2b 122 /*The ECC level (0...3, corresponding to 'L', 'M', 'Q', and 'H').*/
RyoheiHagimoto 0:56c5742b9e2b 123 unsigned char ecc_level;
RyoheiHagimoto 0:56c5742b9e2b 124 /*Structured-append information.*/
RyoheiHagimoto 0:56c5742b9e2b 125 /*The index of this code in the structured-append group.
RyoheiHagimoto 0:56c5742b9e2b 126 If sa_size is zero, this is undefined.*/
RyoheiHagimoto 0:56c5742b9e2b 127 unsigned char sa_index;
RyoheiHagimoto 0:56c5742b9e2b 128 /*The size of the structured-append group, or 0 if there was no S-A header.*/
RyoheiHagimoto 0:56c5742b9e2b 129 unsigned char sa_size;
RyoheiHagimoto 0:56c5742b9e2b 130 /*The parity of the entire structured-append group.
RyoheiHagimoto 0:56c5742b9e2b 131 If sa_size is zero, this is undefined.*/
RyoheiHagimoto 0:56c5742b9e2b 132 unsigned char sa_parity;
RyoheiHagimoto 0:56c5742b9e2b 133 /*The parity of this code.
RyoheiHagimoto 0:56c5742b9e2b 134 If sa_size is zero, this is undefined.*/
RyoheiHagimoto 0:56c5742b9e2b 135 unsigned char self_parity;
RyoheiHagimoto 0:56c5742b9e2b 136 /*An approximate bounding box for the code.
RyoheiHagimoto 0:56c5742b9e2b 137 Points appear in the order up-left, up-right, down-left, down-right,
RyoheiHagimoto 0:56c5742b9e2b 138 relative to the orientation of the QR code.*/
RyoheiHagimoto 0:56c5742b9e2b 139 qr_point bbox[4];
RyoheiHagimoto 0:56c5742b9e2b 140 };
RyoheiHagimoto 0:56c5742b9e2b 141
RyoheiHagimoto 0:56c5742b9e2b 142
RyoheiHagimoto 0:56c5742b9e2b 143 struct qr_code_data_list{
RyoheiHagimoto 0:56c5742b9e2b 144 qr_code_data *qrdata;
RyoheiHagimoto 0:56c5742b9e2b 145 int nqrdata;
RyoheiHagimoto 0:56c5742b9e2b 146 int cqrdata;
RyoheiHagimoto 0:56c5742b9e2b 147 };
RyoheiHagimoto 0:56c5742b9e2b 148
RyoheiHagimoto 0:56c5742b9e2b 149
RyoheiHagimoto 0:56c5742b9e2b 150 /*Extract symbol data from a list of QR codes and attach to the image.
RyoheiHagimoto 0:56c5742b9e2b 151 All text is converted to UTF-8.
RyoheiHagimoto 0:56c5742b9e2b 152 Any structured-append group that does not have all of its members is decoded
RyoheiHagimoto 0:56c5742b9e2b 153 as ZBAR_PARTIAL with ZBAR_PARTIAL components for the discontinuities.
RyoheiHagimoto 0:56c5742b9e2b 154 Note that isolated members of a structured-append group may be decoded with
RyoheiHagimoto 0:56c5742b9e2b 155 the wrong character set, since the correct setting cannot be propagated
RyoheiHagimoto 0:56c5742b9e2b 156 between codes.
RyoheiHagimoto 0:56c5742b9e2b 157 Return: The number of symbols which were successfully extracted from the
RyoheiHagimoto 0:56c5742b9e2b 158 codes; this will be at most the number of codes.*/
RyoheiHagimoto 0:56c5742b9e2b 159 int qr_code_data_list_extract_text(const qr_code_data_list *_qrlist,
RyoheiHagimoto 0:56c5742b9e2b 160 zbar_image_scanner_t *iscn,
RyoheiHagimoto 0:56c5742b9e2b 161 zbar_image_t *img);
RyoheiHagimoto 0:56c5742b9e2b 162
RyoheiHagimoto 0:56c5742b9e2b 163
RyoheiHagimoto 0:56c5742b9e2b 164 /*TODO: Parse DoCoMo standard barcode data formats.
RyoheiHagimoto 0:56c5742b9e2b 165 See http://www.nttdocomo.co.jp/english/service/imode/make/content/barcode/function/application/
RyoheiHagimoto 0:56c5742b9e2b 166 for details.*/
RyoheiHagimoto 0:56c5742b9e2b 167
RyoheiHagimoto 0:56c5742b9e2b 168 #endif
RyoheiHagimoto 0:56c5742b9e2b 169