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
qr_finder.c
00001 #include <config.h> 00002 #include <assert.h> 00003 00004 #include <zbar.h> 00005 #include "decoder.h" 00006 00007 #ifdef DEBUG_QR_FINDER 00008 # define DEBUG_LEVEL (DEBUG_QR_FINDER) 00009 #endif 00010 #include "zbar_debug.h" 00011 00012 /* at this point lengths are all decode unit offsets from the decode edge 00013 * NB owned by finder 00014 */ 00015 qr_finder_line *_zbar_decoder_get_qr_finder_line (zbar_decoder_t *dcode) 00016 { 00017 return(&dcode->qrf.line); 00018 } 00019 00020 zbar_symbol_type_t _zbar_find_qr (zbar_decoder_t *dcode) 00021 { 00022 qr_finder_t *qrf = &dcode->qrf; 00023 00024 /* update latest finder pattern width */ 00025 qrf->s5 -= get_width(dcode, 6); 00026 qrf->s5 += get_width(dcode, 1); 00027 unsigned s = qrf->s5; 00028 00029 if(get_color(dcode) != ZBAR_SPACE || s < 7) 00030 return(0); 00031 00032 dprintf(2, " qrf: s=%d", s); 00033 00034 int ei = decode_e(pair_width(dcode, 1), s, 7); 00035 dprintf(2, " %d", ei); 00036 if(ei) 00037 goto invalid; 00038 00039 ei = decode_e(pair_width(dcode, 2), s, 7); 00040 dprintf(2, "%d", ei); 00041 if(ei != 2) 00042 goto invalid; 00043 00044 ei = decode_e(pair_width(dcode, 3), s, 7); 00045 dprintf(2, "%d", ei); 00046 if(ei != 2) 00047 goto invalid; 00048 00049 ei = decode_e(pair_width(dcode, 4), s, 7); 00050 dprintf(2, "%d", ei); 00051 if(ei) 00052 goto invalid; 00053 00054 /* valid QR finder symbol 00055 * mark positions needed by decoder 00056 */ 00057 unsigned qz = get_width(dcode, 0); 00058 unsigned w = get_width(dcode, 1); 00059 qrf->line.eoffs = qz + (w + 1) / 2; 00060 qrf->line.len = qz + w + get_width(dcode, 2); 00061 qrf->line.pos[0] = qrf->line.len + get_width(dcode, 3); 00062 qrf->line.pos[1] = qrf->line.pos[0]; 00063 w = get_width(dcode, 5); 00064 qrf->line.boffs = qrf->line.pos[0] + get_width(dcode, 4) + (w + 1) / 2; 00065 00066 dprintf(2, " boff=%d pos=%d len=%d eoff=%d [valid]\n", 00067 qrf->line.boffs, qrf->line.pos[0], qrf->line.len, 00068 qrf->line.eoffs); 00069 00070 return(ZBAR_QRCODE); 00071 00072 invalid: 00073 dprintf(2, " [invalid]\n"); 00074 return(0); 00075 } 00076
Generated on Tue Jul 12 2022 18:54:12 by 1.7.2