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.
zbar/decoder/qr_finder.c@0:56c5742b9e2b, 2016-04-19 (annotated)
- Committer:
- RyoheiHagimoto
- Date:
- Tue Apr 19 02:00:37 2016 +0000
- Revision:
- 0:56c5742b9e2b
First revicion
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RyoheiHagimoto | 0:56c5742b9e2b | 1 | #include <config.h> |
RyoheiHagimoto | 0:56c5742b9e2b | 2 | #include <assert.h> |
RyoheiHagimoto | 0:56c5742b9e2b | 3 | |
RyoheiHagimoto | 0:56c5742b9e2b | 4 | #include <zbar.h> |
RyoheiHagimoto | 0:56c5742b9e2b | 5 | #include "decoder.h" |
RyoheiHagimoto | 0:56c5742b9e2b | 6 | |
RyoheiHagimoto | 0:56c5742b9e2b | 7 | #ifdef DEBUG_QR_FINDER |
RyoheiHagimoto | 0:56c5742b9e2b | 8 | # define DEBUG_LEVEL (DEBUG_QR_FINDER) |
RyoheiHagimoto | 0:56c5742b9e2b | 9 | #endif |
RyoheiHagimoto | 0:56c5742b9e2b | 10 | #include "zbar_debug.h" |
RyoheiHagimoto | 0:56c5742b9e2b | 11 | |
RyoheiHagimoto | 0:56c5742b9e2b | 12 | /* at this point lengths are all decode unit offsets from the decode edge |
RyoheiHagimoto | 0:56c5742b9e2b | 13 | * NB owned by finder |
RyoheiHagimoto | 0:56c5742b9e2b | 14 | */ |
RyoheiHagimoto | 0:56c5742b9e2b | 15 | qr_finder_line *_zbar_decoder_get_qr_finder_line (zbar_decoder_t *dcode) |
RyoheiHagimoto | 0:56c5742b9e2b | 16 | { |
RyoheiHagimoto | 0:56c5742b9e2b | 17 | return(&dcode->qrf.line); |
RyoheiHagimoto | 0:56c5742b9e2b | 18 | } |
RyoheiHagimoto | 0:56c5742b9e2b | 19 | |
RyoheiHagimoto | 0:56c5742b9e2b | 20 | zbar_symbol_type_t _zbar_find_qr (zbar_decoder_t *dcode) |
RyoheiHagimoto | 0:56c5742b9e2b | 21 | { |
RyoheiHagimoto | 0:56c5742b9e2b | 22 | qr_finder_t *qrf = &dcode->qrf; |
RyoheiHagimoto | 0:56c5742b9e2b | 23 | |
RyoheiHagimoto | 0:56c5742b9e2b | 24 | /* update latest finder pattern width */ |
RyoheiHagimoto | 0:56c5742b9e2b | 25 | qrf->s5 -= get_width(dcode, 6); |
RyoheiHagimoto | 0:56c5742b9e2b | 26 | qrf->s5 += get_width(dcode, 1); |
RyoheiHagimoto | 0:56c5742b9e2b | 27 | unsigned s = qrf->s5; |
RyoheiHagimoto | 0:56c5742b9e2b | 28 | |
RyoheiHagimoto | 0:56c5742b9e2b | 29 | if(get_color(dcode) != ZBAR_SPACE || s < 7) |
RyoheiHagimoto | 0:56c5742b9e2b | 30 | return(0); |
RyoheiHagimoto | 0:56c5742b9e2b | 31 | |
RyoheiHagimoto | 0:56c5742b9e2b | 32 | dprintf(2, " qrf: s=%d", s); |
RyoheiHagimoto | 0:56c5742b9e2b | 33 | |
RyoheiHagimoto | 0:56c5742b9e2b | 34 | int ei = decode_e(pair_width(dcode, 1), s, 7); |
RyoheiHagimoto | 0:56c5742b9e2b | 35 | dprintf(2, " %d", ei); |
RyoheiHagimoto | 0:56c5742b9e2b | 36 | if(ei) |
RyoheiHagimoto | 0:56c5742b9e2b | 37 | goto invalid; |
RyoheiHagimoto | 0:56c5742b9e2b | 38 | |
RyoheiHagimoto | 0:56c5742b9e2b | 39 | ei = decode_e(pair_width(dcode, 2), s, 7); |
RyoheiHagimoto | 0:56c5742b9e2b | 40 | dprintf(2, "%d", ei); |
RyoheiHagimoto | 0:56c5742b9e2b | 41 | if(ei != 2) |
RyoheiHagimoto | 0:56c5742b9e2b | 42 | goto invalid; |
RyoheiHagimoto | 0:56c5742b9e2b | 43 | |
RyoheiHagimoto | 0:56c5742b9e2b | 44 | ei = decode_e(pair_width(dcode, 3), s, 7); |
RyoheiHagimoto | 0:56c5742b9e2b | 45 | dprintf(2, "%d", ei); |
RyoheiHagimoto | 0:56c5742b9e2b | 46 | if(ei != 2) |
RyoheiHagimoto | 0:56c5742b9e2b | 47 | goto invalid; |
RyoheiHagimoto | 0:56c5742b9e2b | 48 | |
RyoheiHagimoto | 0:56c5742b9e2b | 49 | ei = decode_e(pair_width(dcode, 4), s, 7); |
RyoheiHagimoto | 0:56c5742b9e2b | 50 | dprintf(2, "%d", ei); |
RyoheiHagimoto | 0:56c5742b9e2b | 51 | if(ei) |
RyoheiHagimoto | 0:56c5742b9e2b | 52 | goto invalid; |
RyoheiHagimoto | 0:56c5742b9e2b | 53 | |
RyoheiHagimoto | 0:56c5742b9e2b | 54 | /* valid QR finder symbol |
RyoheiHagimoto | 0:56c5742b9e2b | 55 | * mark positions needed by decoder |
RyoheiHagimoto | 0:56c5742b9e2b | 56 | */ |
RyoheiHagimoto | 0:56c5742b9e2b | 57 | unsigned qz = get_width(dcode, 0); |
RyoheiHagimoto | 0:56c5742b9e2b | 58 | unsigned w = get_width(dcode, 1); |
RyoheiHagimoto | 0:56c5742b9e2b | 59 | qrf->line.eoffs = qz + (w + 1) / 2; |
RyoheiHagimoto | 0:56c5742b9e2b | 60 | qrf->line.len = qz + w + get_width(dcode, 2); |
RyoheiHagimoto | 0:56c5742b9e2b | 61 | qrf->line.pos[0] = qrf->line.len + get_width(dcode, 3); |
RyoheiHagimoto | 0:56c5742b9e2b | 62 | qrf->line.pos[1] = qrf->line.pos[0]; |
RyoheiHagimoto | 0:56c5742b9e2b | 63 | w = get_width(dcode, 5); |
RyoheiHagimoto | 0:56c5742b9e2b | 64 | qrf->line.boffs = qrf->line.pos[0] + get_width(dcode, 4) + (w + 1) / 2; |
RyoheiHagimoto | 0:56c5742b9e2b | 65 | |
RyoheiHagimoto | 0:56c5742b9e2b | 66 | dprintf(2, " boff=%d pos=%d len=%d eoff=%d [valid]\n", |
RyoheiHagimoto | 0:56c5742b9e2b | 67 | qrf->line.boffs, qrf->line.pos[0], qrf->line.len, |
RyoheiHagimoto | 0:56c5742b9e2b | 68 | qrf->line.eoffs); |
RyoheiHagimoto | 0:56c5742b9e2b | 69 | |
RyoheiHagimoto | 0:56c5742b9e2b | 70 | return(ZBAR_QRCODE); |
RyoheiHagimoto | 0:56c5742b9e2b | 71 | |
RyoheiHagimoto | 0:56c5742b9e2b | 72 | invalid: |
RyoheiHagimoto | 0:56c5742b9e2b | 73 | dprintf(2, " [invalid]\n"); |
RyoheiHagimoto | 0:56c5742b9e2b | 74 | return(0); |
RyoheiHagimoto | 0:56c5742b9e2b | 75 | } |
RyoheiHagimoto | 0:56c5742b9e2b | 76 |