A streamlined version (for embedded use) of Jeff Brown's ZBar library. Visit <http://zbar.sourceforge.net> for more details.

Dependents:   BarcodeReader_F103

Committer:
hudakz
Date:
Fri Jan 10 22:06:18 2020 +0000
Revision:
1:4f5c042a2d34
Parent:
0:e33621169e44
Streamlined barcode reader library.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hudakz 0:e33621169e44 1 /*------------------------------------------------------------------------
hudakz 0:e33621169e44 2 * Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
hudakz 0:e33621169e44 3 *
hudakz 0:e33621169e44 4 * This file is part of the ZBar Bar Code Reader.
hudakz 0:e33621169e44 5 *
hudakz 0:e33621169e44 6 * The ZBar Bar Code Reader is free software; you can redistribute it
hudakz 0:e33621169e44 7 * and/or modify it under the terms of the GNU Lesser Public License as
hudakz 0:e33621169e44 8 * published by the Free Software Foundation; either version 2.1 of
hudakz 0:e33621169e44 9 * the License, or (at your option) any later version.
hudakz 0:e33621169e44 10 *
hudakz 0:e33621169e44 11 * The ZBar Bar Code Reader is distributed in the hope that it will be
hudakz 0:e33621169e44 12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
hudakz 0:e33621169e44 13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
hudakz 0:e33621169e44 14 * GNU Lesser Public License for more details.
hudakz 0:e33621169e44 15 *
hudakz 0:e33621169e44 16 * You should have received a copy of the GNU Lesser Public License
hudakz 0:e33621169e44 17 * along with the ZBar Bar Code Reader; if not, write to the Free
hudakz 0:e33621169e44 18 * Software Foundation, Inc., 51 Franklin St, Fifth Floor,
hudakz 0:e33621169e44 19 * Boston, MA 02110-1301 USA
hudakz 0:e33621169e44 20 *
hudakz 0:e33621169e44 21 * http://sourceforge.net/projects/zbar
hudakz 0:e33621169e44 22 *------------------------------------------------------------------------*/
hudakz 0:e33621169e44 23 #ifndef _SYMBOL_H_
hudakz 0:e33621169e44 24 #define _SYMBOL_H_
hudakz 0:e33621169e44 25
hudakz 0:e33621169e44 26 #include <stdlib.h>
hudakz 0:e33621169e44 27 #include <zbar.h>
hudakz 0:e33621169e44 28 #include "refcnt.h"
hudakz 0:e33621169e44 29
hudakz 0:e33621169e44 30 typedef struct point_s {
hudakz 0:e33621169e44 31 int x, y;
hudakz 0:e33621169e44 32 } point_t;
hudakz 0:e33621169e44 33
hudakz 0:e33621169e44 34 struct zbar_symbol_set_s {
hudakz 0:e33621169e44 35 refcnt_t refcnt;
hudakz 0:e33621169e44 36 int nsyms; /* number of filtered symbols */
hudakz 0:e33621169e44 37 zbar_symbol_t *head; /* first of decoded symbol results */
hudakz 0:e33621169e44 38 zbar_symbol_t *tail; /* last of unfiltered symbol results */
hudakz 0:e33621169e44 39 };
hudakz 0:e33621169e44 40
hudakz 0:e33621169e44 41 struct zbar_symbol_s {
hudakz 0:e33621169e44 42 zbar_symbol_type_t type; /* symbol type */
hudakz 0:e33621169e44 43 unsigned int data_alloc; /* allocation size of data */
hudakz 0:e33621169e44 44 unsigned int datalen; /* length of binary symbol data */
hudakz 0:e33621169e44 45 char *data; /* symbol data */
hudakz 0:e33621169e44 46
hudakz 0:e33621169e44 47 unsigned pts_alloc; /* allocation size of pts */
hudakz 0:e33621169e44 48 unsigned npts; /* number of points in location polygon */
hudakz 0:e33621169e44 49 point_t *pts; /* list of points in location polygon */
hudakz 0:e33621169e44 50
hudakz 0:e33621169e44 51 refcnt_t refcnt; /* reference count */
hudakz 0:e33621169e44 52 zbar_symbol_t *next; /* linked list of results (or siblings) */
hudakz 0:e33621169e44 53 zbar_symbol_set_t *syms; /* components of composite result */
hudakz 0:e33621169e44 54 unsigned long time; /* relative symbol capture time */
hudakz 0:e33621169e44 55 int cache_count; /* cache state */
hudakz 0:e33621169e44 56 int quality; /* relative symbol reliability metric */
hudakz 0:e33621169e44 57 };
hudakz 0:e33621169e44 58
hudakz 0:e33621169e44 59 extern void _zbar_symbol_free(zbar_symbol_t*);
hudakz 0:e33621169e44 60
hudakz 0:e33621169e44 61 extern zbar_symbol_set_t *_zbar_symbol_set_create(void);
hudakz 0:e33621169e44 62 extern void _zbar_symbol_set_free(zbar_symbol_set_t*);
hudakz 0:e33621169e44 63
hudakz 0:e33621169e44 64 static inline void sym_add_point (zbar_symbol_t *sym,
hudakz 0:e33621169e44 65 int x,
hudakz 0:e33621169e44 66 int y)
hudakz 0:e33621169e44 67 {
hudakz 0:e33621169e44 68 int i = sym->npts;
hudakz 0:e33621169e44 69 if(++sym->npts >= sym->pts_alloc)
hudakz 0:e33621169e44 70 sym->pts = realloc(sym->pts, ++sym->pts_alloc * sizeof(point_t));
hudakz 0:e33621169e44 71 sym->pts[i].x = x;
hudakz 0:e33621169e44 72 sym->pts[i].y = y;
hudakz 0:e33621169e44 73 }
hudakz 0:e33621169e44 74
hudakz 0:e33621169e44 75 static inline void _zbar_symbol_refcnt (zbar_symbol_t *sym,
hudakz 0:e33621169e44 76 int delta)
hudakz 0:e33621169e44 77 {
hudakz 0:e33621169e44 78 if(!_zbar_refcnt(&sym->refcnt, delta) && delta <= 0)
hudakz 0:e33621169e44 79 _zbar_symbol_free(sym);
hudakz 0:e33621169e44 80 }
hudakz 0:e33621169e44 81
hudakz 0:e33621169e44 82 static inline void _zbar_symbol_set_add (zbar_symbol_set_t *syms,
hudakz 0:e33621169e44 83 zbar_symbol_t *sym)
hudakz 0:e33621169e44 84 {
hudakz 0:e33621169e44 85 sym->next = syms->head;
hudakz 0:e33621169e44 86 syms->head = sym;
hudakz 0:e33621169e44 87 syms->nsyms++;
hudakz 0:e33621169e44 88
hudakz 0:e33621169e44 89 _zbar_symbol_refcnt(sym, 1);
hudakz 0:e33621169e44 90 }
hudakz 0:e33621169e44 91
hudakz 0:e33621169e44 92 #endif