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.

Revision:
0:56c5742b9e2b
diff -r 000000000000 -r 56c5742b9e2b zbar/decoder/qr_finder.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zbar/decoder/qr_finder.c	Tue Apr 19 02:00:37 2016 +0000
@@ -0,0 +1,76 @@
+#include <config.h>
+#include <assert.h>
+
+#include <zbar.h>
+#include "decoder.h"
+
+#ifdef DEBUG_QR_FINDER
+# define DEBUG_LEVEL (DEBUG_QR_FINDER)
+#endif
+#include "zbar_debug.h"
+
+/* at this point lengths are all decode unit offsets from the decode edge
+ * NB owned by finder
+ */
+qr_finder_line *_zbar_decoder_get_qr_finder_line (zbar_decoder_t *dcode)
+{
+    return(&dcode->qrf.line);
+}
+
+zbar_symbol_type_t _zbar_find_qr (zbar_decoder_t *dcode)
+{
+    qr_finder_t *qrf = &dcode->qrf;
+
+    /* update latest finder pattern width */
+    qrf->s5 -= get_width(dcode, 6);
+    qrf->s5 += get_width(dcode, 1);
+    unsigned s = qrf->s5;
+
+    if(get_color(dcode) != ZBAR_SPACE || s < 7)
+        return(0);
+
+    dprintf(2, "    qrf: s=%d", s);
+
+    int ei = decode_e(pair_width(dcode, 1), s, 7);
+    dprintf(2, " %d", ei);
+    if(ei)
+        goto invalid;
+
+    ei = decode_e(pair_width(dcode, 2), s, 7);
+    dprintf(2, "%d", ei);
+    if(ei != 2)
+        goto invalid;
+
+    ei = decode_e(pair_width(dcode, 3), s, 7);
+    dprintf(2, "%d", ei);
+    if(ei != 2)
+        goto invalid;
+
+    ei = decode_e(pair_width(dcode, 4), s, 7);
+    dprintf(2, "%d", ei);
+    if(ei)
+        goto invalid;
+
+    /* valid QR finder symbol
+     * mark positions needed by decoder
+     */
+    unsigned qz = get_width(dcode, 0);
+    unsigned w = get_width(dcode, 1);
+    qrf->line.eoffs = qz + (w + 1) / 2;
+    qrf->line.len = qz + w + get_width(dcode, 2);
+    qrf->line.pos[0] = qrf->line.len + get_width(dcode, 3);
+    qrf->line.pos[1] = qrf->line.pos[0];
+    w = get_width(dcode, 5);
+    qrf->line.boffs = qrf->line.pos[0] + get_width(dcode, 4) + (w + 1) / 2;
+
+    dprintf(2, " boff=%d pos=%d len=%d eoff=%d [valid]\n",
+            qrf->line.boffs, qrf->line.pos[0], qrf->line.len,
+            qrf->line.eoffs);
+
+    return(ZBAR_QRCODE);
+
+invalid:
+    dprintf(2, " [invalid]\n");
+    return(0);
+}
+