Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: BarcodeReader_F103
include/zbar.h@0:e33621169e44, 2020-01-10 (annotated)
- Committer:
- hudakz
- Date:
- Fri Jan 10 20:29:52 2020 +0000
- Revision:
- 0:e33621169e44
Streamlined barcode reader library.
Who changed what in which revision?
User | Revision | Line number | New 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 _ZBAR_H_ |
hudakz | 0:e33621169e44 | 24 | #define _ZBAR_H_ |
hudakz | 0:e33621169e44 | 25 | |
hudakz | 0:e33621169e44 | 26 | /** @file |
hudakz | 0:e33621169e44 | 27 | * ZBar Barcode Reader C API definition |
hudakz | 0:e33621169e44 | 28 | */ |
hudakz | 0:e33621169e44 | 29 | |
hudakz | 0:e33621169e44 | 30 | /** @mainpage |
hudakz | 0:e33621169e44 | 31 | * |
hudakz | 0:e33621169e44 | 32 | * interface to the barcode reader is available at several levels. |
hudakz | 0:e33621169e44 | 33 | * most applications will want to use the high-level interfaces: |
hudakz | 0:e33621169e44 | 34 | * |
hudakz | 0:e33621169e44 | 35 | * @section high-level High-Level Interfaces |
hudakz | 0:e33621169e44 | 36 | * |
hudakz | 0:e33621169e44 | 37 | * these interfaces wrap all library functionality into an easy-to-use |
hudakz | 0:e33621169e44 | 38 | * package for a specific toolkit: |
hudakz | 0:e33621169e44 | 39 | * - the "GTK+ 2.x widget" may be used with GTK GUI applications. a |
hudakz | 0:e33621169e44 | 40 | * Python wrapper is included for PyGtk |
hudakz | 0:e33621169e44 | 41 | * - the @ref zbar::QZBar "Qt4 widget" may be used with Qt GUI |
hudakz | 0:e33621169e44 | 42 | * applications |
hudakz | 0:e33621169e44 | 43 | * - the Processor interface (in @ref c-processor "C" or @ref |
hudakz | 0:e33621169e44 | 44 | * zbar::Processor "C++") adds a scanning window to an application |
hudakz | 0:e33621169e44 | 45 | * with no GUI. |
hudakz | 0:e33621169e44 | 46 | * |
hudakz | 0:e33621169e44 | 47 | * @section mid-level Intermediate Interfaces |
hudakz | 0:e33621169e44 | 48 | * |
hudakz | 0:e33621169e44 | 49 | * building blocks used to construct high-level interfaces: |
hudakz | 0:e33621169e44 | 50 | * - the ImageScanner (in @ref c-imagescanner "C" or @ref |
hudakz | 0:e33621169e44 | 51 | * zbar::ImageScanner "C++") looks for barcodes in a library defined |
hudakz | 0:e33621169e44 | 52 | * image object |
hudakz | 0:e33621169e44 | 53 | * - the Window abstraction (in @ref c-window "C" or @ref |
hudakz | 0:e33621169e44 | 54 | * zbar::Window "C++") sinks library images, displaying them on the |
hudakz | 0:e33621169e44 | 55 | * platform display |
hudakz | 0:e33621169e44 | 56 | * - the Video abstraction (in @ref c-video "C" or @ref zbar::Video |
hudakz | 0:e33621169e44 | 57 | * "C++") sources library images from a video device |
hudakz | 0:e33621169e44 | 58 | * |
hudakz | 0:e33621169e44 | 59 | * @section low-level Low-Level Interfaces |
hudakz | 0:e33621169e44 | 60 | * |
hudakz | 0:e33621169e44 | 61 | * direct interaction with barcode scanning and decoding: |
hudakz | 0:e33621169e44 | 62 | * - the Scanner (in @ref c-scanner "C" or @ref zbar::Scanner "C++") |
hudakz | 0:e33621169e44 | 63 | * looks for barcodes in a linear intensity sample stream |
hudakz | 0:e33621169e44 | 64 | * - the Decoder (in @ref c-decoder "C" or @ref zbar::Decoder "C++") |
hudakz | 0:e33621169e44 | 65 | * extracts barcodes from a stream of bar and space widths |
hudakz | 0:e33621169e44 | 66 | */ |
hudakz | 0:e33621169e44 | 67 | |
hudakz | 0:e33621169e44 | 68 | #ifdef __cplusplus |
hudakz | 0:e33621169e44 | 69 | |
hudakz | 0:e33621169e44 | 70 | /** C++ namespace for library interfaces */ |
hudakz | 0:e33621169e44 | 71 | namespace zbar { |
hudakz | 0:e33621169e44 | 72 | extern "C" { |
hudakz | 0:e33621169e44 | 73 | #endif |
hudakz | 0:e33621169e44 | 74 | |
hudakz | 0:e33621169e44 | 75 | |
hudakz | 0:e33621169e44 | 76 | /** @name Global library interfaces */ |
hudakz | 0:e33621169e44 | 77 | /*@{*/ |
hudakz | 0:e33621169e44 | 78 | |
hudakz | 0:e33621169e44 | 79 | /** "color" of element: bar or space. */ |
hudakz | 0:e33621169e44 | 80 | typedef enum zbar_color_e { |
hudakz | 0:e33621169e44 | 81 | ZBAR_SPACE = 0, /**< light area or space between bars */ |
hudakz | 0:e33621169e44 | 82 | ZBAR_BAR = 1, /**< dark area or colored bar segment */ |
hudakz | 0:e33621169e44 | 83 | } zbar_color_t; |
hudakz | 0:e33621169e44 | 84 | |
hudakz | 0:e33621169e44 | 85 | /** decoded symbol type. */ |
hudakz | 0:e33621169e44 | 86 | typedef enum zbar_symbol_type_e { |
hudakz | 0:e33621169e44 | 87 | ZBAR_NONE = 0, /**< no symbol decoded */ |
hudakz | 0:e33621169e44 | 88 | ZBAR_PARTIAL = 1, /**< intermediate status */ |
hudakz | 0:e33621169e44 | 89 | ZBAR_EAN8 = 8, /**< EAN-8 */ |
hudakz | 0:e33621169e44 | 90 | ZBAR_UPCE = 9, /**< UPC-E */ |
hudakz | 0:e33621169e44 | 91 | ZBAR_ISBN10 = 10, /**< ISBN-10 (from EAN-13). @since 0.4 */ |
hudakz | 0:e33621169e44 | 92 | ZBAR_UPCA = 12, /**< UPC-A */ |
hudakz | 0:e33621169e44 | 93 | ZBAR_EAN13 = 13, /**< EAN-13 */ |
hudakz | 0:e33621169e44 | 94 | ZBAR_ISBN13 = 14, /**< ISBN-13 (from EAN-13). @since 0.4 */ |
hudakz | 0:e33621169e44 | 95 | ZBAR_I25 = 25, /**< Interleaved 2 of 5. @since 0.4 */ |
hudakz | 0:e33621169e44 | 96 | ZBAR_CODE39 = 39, /**< Code 39. @since 0.4 */ |
hudakz | 0:e33621169e44 | 97 | ZBAR_PDF417 = 57, /**< PDF417. @since 0.6 */ |
hudakz | 0:e33621169e44 | 98 | ZBAR_QRCODE = 64, /**< QR Code. @since 0.10 */ |
hudakz | 0:e33621169e44 | 99 | ZBAR_CODE128 = 128, /**< Code 128 */ |
hudakz | 0:e33621169e44 | 100 | ZBAR_SYMBOL = 0x00ff, /**< mask for base symbol type */ |
hudakz | 0:e33621169e44 | 101 | ZBAR_ADDON2 = 0x0200, /**< 2-digit add-on flag */ |
hudakz | 0:e33621169e44 | 102 | ZBAR_ADDON5 = 0x0500, /**< 5-digit add-on flag */ |
hudakz | 0:e33621169e44 | 103 | ZBAR_ADDON = 0x0700, /**< add-on flag mask */ |
hudakz | 0:e33621169e44 | 104 | } zbar_symbol_type_t; |
hudakz | 0:e33621169e44 | 105 | |
hudakz | 0:e33621169e44 | 106 | /** error codes. */ |
hudakz | 0:e33621169e44 | 107 | typedef enum zbar_error_e { |
hudakz | 0:e33621169e44 | 108 | ZBAR_OK = 0, /**< no error */ |
hudakz | 0:e33621169e44 | 109 | ZBAR_ERR_NOMEM, /**< out of memory */ |
hudakz | 0:e33621169e44 | 110 | ZBAR_ERR_INTERNAL, /**< internal library error */ |
hudakz | 0:e33621169e44 | 111 | ZBAR_ERR_UNSUPPORTED, /**< unsupported request */ |
hudakz | 0:e33621169e44 | 112 | ZBAR_ERR_INVALID, /**< invalid request */ |
hudakz | 0:e33621169e44 | 113 | ZBAR_ERR_SYSTEM, /**< system error */ |
hudakz | 0:e33621169e44 | 114 | ZBAR_ERR_LOCKING, /**< locking error */ |
hudakz | 0:e33621169e44 | 115 | ZBAR_ERR_BUSY, /**< all resources busy */ |
hudakz | 0:e33621169e44 | 116 | ZBAR_ERR_XDISPLAY, /**< X11 display error */ |
hudakz | 0:e33621169e44 | 117 | ZBAR_ERR_XPROTO, /**< X11 protocol error */ |
hudakz | 0:e33621169e44 | 118 | ZBAR_ERR_CLOSED, /**< output window is closed */ |
hudakz | 0:e33621169e44 | 119 | ZBAR_ERR_WINAPI, /**< windows system error */ |
hudakz | 0:e33621169e44 | 120 | ZBAR_ERR_NUM /**< number of error codes */ |
hudakz | 0:e33621169e44 | 121 | } zbar_error_t; |
hudakz | 0:e33621169e44 | 122 | |
hudakz | 0:e33621169e44 | 123 | /** decoder configuration options. |
hudakz | 0:e33621169e44 | 124 | * @since 0.4 |
hudakz | 0:e33621169e44 | 125 | */ |
hudakz | 0:e33621169e44 | 126 | typedef enum zbar_config_e { |
hudakz | 0:e33621169e44 | 127 | ZBAR_CFG_ENABLE = 0, /**< enable symbology/feature */ |
hudakz | 0:e33621169e44 | 128 | ZBAR_CFG_ADD_CHECK, /**< enable check digit when optional */ |
hudakz | 0:e33621169e44 | 129 | ZBAR_CFG_EMIT_CHECK, /**< return check digit when present */ |
hudakz | 0:e33621169e44 | 130 | ZBAR_CFG_ASCII, /**< enable full ASCII character set */ |
hudakz | 0:e33621169e44 | 131 | ZBAR_CFG_NUM, /**< number of boolean decoder configs */ |
hudakz | 0:e33621169e44 | 132 | |
hudakz | 0:e33621169e44 | 133 | ZBAR_CFG_MIN_LEN = 0x20, /**< minimum data length for valid decode */ |
hudakz | 0:e33621169e44 | 134 | ZBAR_CFG_MAX_LEN, /**< maximum data length for valid decode */ |
hudakz | 0:e33621169e44 | 135 | |
hudakz | 0:e33621169e44 | 136 | ZBAR_CFG_POSITION = 0x80, /**< enable scanner to collect position data */ |
hudakz | 0:e33621169e44 | 137 | |
hudakz | 0:e33621169e44 | 138 | ZBAR_CFG_X_DENSITY = 0x100, /**< image scanner vertical scan density */ |
hudakz | 0:e33621169e44 | 139 | ZBAR_CFG_Y_DENSITY, /**< image scanner horizontal scan density */ |
hudakz | 0:e33621169e44 | 140 | } zbar_config_t; |
hudakz | 0:e33621169e44 | 141 | |
hudakz | 0:e33621169e44 | 142 | /** retrieve runtime library version information. |
hudakz | 0:e33621169e44 | 143 | * @param major set to the running major version (unless NULL) |
hudakz | 0:e33621169e44 | 144 | * @param minor set to the running minor version (unless NULL) |
hudakz | 0:e33621169e44 | 145 | * @returns 0 |
hudakz | 0:e33621169e44 | 146 | */ |
hudakz | 0:e33621169e44 | 147 | extern int zbar_version(unsigned *major, |
hudakz | 0:e33621169e44 | 148 | unsigned *minor); |
hudakz | 0:e33621169e44 | 149 | |
hudakz | 0:e33621169e44 | 150 | /** set global library debug level. |
hudakz | 0:e33621169e44 | 151 | * @param verbosity desired debug level. higher values create more spew |
hudakz | 0:e33621169e44 | 152 | */ |
hudakz | 0:e33621169e44 | 153 | extern void zbar_set_verbosity(int verbosity); |
hudakz | 0:e33621169e44 | 154 | |
hudakz | 0:e33621169e44 | 155 | /** increase global library debug level. |
hudakz | 0:e33621169e44 | 156 | * eg, for -vvvv |
hudakz | 0:e33621169e44 | 157 | */ |
hudakz | 0:e33621169e44 | 158 | extern void zbar_increase_verbosity(void); |
hudakz | 0:e33621169e44 | 159 | |
hudakz | 0:e33621169e44 | 160 | /** retrieve string name for symbol encoding. |
hudakz | 0:e33621169e44 | 161 | * @param sym symbol type encoding |
hudakz | 0:e33621169e44 | 162 | * @returns the static string name for the specified symbol type, |
hudakz | 0:e33621169e44 | 163 | * or "UNKNOWN" if the encoding is not recognized |
hudakz | 0:e33621169e44 | 164 | */ |
hudakz | 0:e33621169e44 | 165 | extern const char *zbar_get_symbol_name(zbar_symbol_type_t sym); |
hudakz | 0:e33621169e44 | 166 | |
hudakz | 0:e33621169e44 | 167 | /** retrieve string name for addon encoding. |
hudakz | 0:e33621169e44 | 168 | * @param sym symbol type encoding |
hudakz | 0:e33621169e44 | 169 | * @returns static string name for any addon, or the empty string |
hudakz | 0:e33621169e44 | 170 | * if no addons were decoded |
hudakz | 0:e33621169e44 | 171 | */ |
hudakz | 0:e33621169e44 | 172 | extern const char *zbar_get_addon_name(zbar_symbol_type_t sym); |
hudakz | 0:e33621169e44 | 173 | |
hudakz | 0:e33621169e44 | 174 | /** parse a configuration string of the form "[symbology.]config[=value]". |
hudakz | 0:e33621169e44 | 175 | * the config must match one of the recognized names. |
hudakz | 0:e33621169e44 | 176 | * the symbology, if present, must match one of the recognized names. |
hudakz | 0:e33621169e44 | 177 | * if symbology is unspecified, it will be set to 0. |
hudakz | 0:e33621169e44 | 178 | * if value is unspecified it will be set to 1. |
hudakz | 0:e33621169e44 | 179 | * @returns 0 if the config is parsed successfully, 1 otherwise |
hudakz | 0:e33621169e44 | 180 | * @since 0.4 |
hudakz | 0:e33621169e44 | 181 | */ |
hudakz | 0:e33621169e44 | 182 | extern int zbar_parse_config(const char *config_string, |
hudakz | 0:e33621169e44 | 183 | zbar_symbol_type_t *symbology, |
hudakz | 0:e33621169e44 | 184 | zbar_config_t *config, |
hudakz | 0:e33621169e44 | 185 | int *value); |
hudakz | 0:e33621169e44 | 186 | |
hudakz | 0:e33621169e44 | 187 | /** @internal type unsafe error API (don't use) */ |
hudakz | 0:e33621169e44 | 188 | extern int _zbar_error_spew(const void *object, |
hudakz | 0:e33621169e44 | 189 | int verbosity); |
hudakz | 0:e33621169e44 | 190 | extern const char *_zbar_error_string(const void *object, |
hudakz | 0:e33621169e44 | 191 | int verbosity); |
hudakz | 0:e33621169e44 | 192 | extern zbar_error_t _zbar_get_error_code(const void *object); |
hudakz | 0:e33621169e44 | 193 | |
hudakz | 0:e33621169e44 | 194 | /*@}*/ |
hudakz | 0:e33621169e44 | 195 | |
hudakz | 0:e33621169e44 | 196 | struct zbar_symbol_s; |
hudakz | 0:e33621169e44 | 197 | typedef struct zbar_symbol_s zbar_symbol_t; |
hudakz | 0:e33621169e44 | 198 | |
hudakz | 0:e33621169e44 | 199 | struct zbar_symbol_set_s; |
hudakz | 0:e33621169e44 | 200 | typedef struct zbar_symbol_set_s zbar_symbol_set_t; |
hudakz | 0:e33621169e44 | 201 | |
hudakz | 0:e33621169e44 | 202 | |
hudakz | 0:e33621169e44 | 203 | /*------------------------------------------------------------*/ |
hudakz | 0:e33621169e44 | 204 | /** @name Symbol interface |
hudakz | 0:e33621169e44 | 205 | * decoded barcode symbol result object. stores type, data, and image |
hudakz | 0:e33621169e44 | 206 | * location of decoded symbol. all memory is owned by the library |
hudakz | 0:e33621169e44 | 207 | */ |
hudakz | 0:e33621169e44 | 208 | /*@{*/ |
hudakz | 0:e33621169e44 | 209 | |
hudakz | 0:e33621169e44 | 210 | /** @typedef zbar_symbol_t |
hudakz | 0:e33621169e44 | 211 | * opaque decoded symbol object. |
hudakz | 0:e33621169e44 | 212 | */ |
hudakz | 0:e33621169e44 | 213 | |
hudakz | 0:e33621169e44 | 214 | /** symbol reference count manipulation. |
hudakz | 0:e33621169e44 | 215 | * increment the reference count when you store a new reference to the |
hudakz | 0:e33621169e44 | 216 | * symbol. decrement when the reference is no longer used. do not |
hudakz | 0:e33621169e44 | 217 | * refer to the symbol once the count is decremented and the |
hudakz | 0:e33621169e44 | 218 | * containing image has been recycled or destroyed. |
hudakz | 0:e33621169e44 | 219 | * @note the containing image holds a reference to the symbol, so you |
hudakz | 0:e33621169e44 | 220 | * only need to use this if you keep a symbol after the image has been |
hudakz | 0:e33621169e44 | 221 | * destroyed or reused. |
hudakz | 0:e33621169e44 | 222 | * @since 0.9 |
hudakz | 0:e33621169e44 | 223 | */ |
hudakz | 0:e33621169e44 | 224 | extern void zbar_symbol_ref(const zbar_symbol_t *symbol, |
hudakz | 0:e33621169e44 | 225 | int refs); |
hudakz | 0:e33621169e44 | 226 | |
hudakz | 0:e33621169e44 | 227 | /** retrieve type of decoded symbol. |
hudakz | 0:e33621169e44 | 228 | * @returns the symbol type |
hudakz | 0:e33621169e44 | 229 | */ |
hudakz | 0:e33621169e44 | 230 | extern zbar_symbol_type_t zbar_symbol_get_type(const zbar_symbol_t *symbol); |
hudakz | 0:e33621169e44 | 231 | |
hudakz | 0:e33621169e44 | 232 | /** retrieve data decoded from symbol. |
hudakz | 0:e33621169e44 | 233 | * @returns the data string |
hudakz | 0:e33621169e44 | 234 | */ |
hudakz | 0:e33621169e44 | 235 | extern const char *zbar_symbol_get_data(const zbar_symbol_t *symbol); |
hudakz | 0:e33621169e44 | 236 | |
hudakz | 0:e33621169e44 | 237 | /** retrieve length of binary data. |
hudakz | 0:e33621169e44 | 238 | * @returns the length of the decoded data |
hudakz | 0:e33621169e44 | 239 | */ |
hudakz | 0:e33621169e44 | 240 | extern unsigned int zbar_symbol_get_data_length(const zbar_symbol_t *symbol); |
hudakz | 0:e33621169e44 | 241 | |
hudakz | 0:e33621169e44 | 242 | /** retrieve a symbol confidence metric. |
hudakz | 0:e33621169e44 | 243 | * @returns an unscaled, relative quantity: larger values are better |
hudakz | 0:e33621169e44 | 244 | * than smaller values, where "large" and "small" are application |
hudakz | 0:e33621169e44 | 245 | * dependent. |
hudakz | 0:e33621169e44 | 246 | * @note expect the exact definition of this quantity to change as the |
hudakz | 0:e33621169e44 | 247 | * metric is refined. currently, only the ordered relationship |
hudakz | 0:e33621169e44 | 248 | * between two values is defined and will remain stable in the future |
hudakz | 0:e33621169e44 | 249 | * @since 0.9 |
hudakz | 0:e33621169e44 | 250 | */ |
hudakz | 0:e33621169e44 | 251 | extern int zbar_symbol_get_quality(const zbar_symbol_t *symbol); |
hudakz | 0:e33621169e44 | 252 | |
hudakz | 0:e33621169e44 | 253 | /** retrieve current cache count. when the cache is enabled for the |
hudakz | 0:e33621169e44 | 254 | * image_scanner this provides inter-frame reliability and redundancy |
hudakz | 0:e33621169e44 | 255 | * information for video streams. |
hudakz | 0:e33621169e44 | 256 | * @returns < 0 if symbol is still uncertain. |
hudakz | 0:e33621169e44 | 257 | * @returns 0 if symbol is newly verified. |
hudakz | 0:e33621169e44 | 258 | * @returns > 0 for duplicate symbols |
hudakz | 0:e33621169e44 | 259 | */ |
hudakz | 0:e33621169e44 | 260 | extern int zbar_symbol_get_count(const zbar_symbol_t *symbol); |
hudakz | 0:e33621169e44 | 261 | |
hudakz | 0:e33621169e44 | 262 | /** retrieve the number of points in the location polygon. the |
hudakz | 0:e33621169e44 | 263 | * location polygon defines the image area that the symbol was |
hudakz | 0:e33621169e44 | 264 | * extracted from. |
hudakz | 0:e33621169e44 | 265 | * @returns the number of points in the location polygon |
hudakz | 0:e33621169e44 | 266 | * @note this is currently not a polygon, but the scan locations |
hudakz | 0:e33621169e44 | 267 | * where the symbol was decoded |
hudakz | 0:e33621169e44 | 268 | */ |
hudakz | 0:e33621169e44 | 269 | extern unsigned zbar_symbol_get_loc_size(const zbar_symbol_t *symbol); |
hudakz | 0:e33621169e44 | 270 | |
hudakz | 0:e33621169e44 | 271 | /** retrieve location polygon x-coordinates. |
hudakz | 0:e33621169e44 | 272 | * points are specified by 0-based index. |
hudakz | 0:e33621169e44 | 273 | * @returns the x-coordinate for a point in the location polygon. |
hudakz | 0:e33621169e44 | 274 | * @returns -1 if index is out of range |
hudakz | 0:e33621169e44 | 275 | */ |
hudakz | 0:e33621169e44 | 276 | extern int zbar_symbol_get_loc_x(const zbar_symbol_t *symbol, |
hudakz | 0:e33621169e44 | 277 | unsigned index); |
hudakz | 0:e33621169e44 | 278 | |
hudakz | 0:e33621169e44 | 279 | /** retrieve location polygon y-coordinates. |
hudakz | 0:e33621169e44 | 280 | * points are specified by 0-based index. |
hudakz | 0:e33621169e44 | 281 | * @returns the y-coordinate for a point in the location polygon. |
hudakz | 0:e33621169e44 | 282 | * @returns -1 if index is out of range |
hudakz | 0:e33621169e44 | 283 | */ |
hudakz | 0:e33621169e44 | 284 | extern int zbar_symbol_get_loc_y(const zbar_symbol_t *symbol, |
hudakz | 0:e33621169e44 | 285 | unsigned index); |
hudakz | 0:e33621169e44 | 286 | |
hudakz | 0:e33621169e44 | 287 | /** iterate the set to which this symbol belongs (there can be only one). |
hudakz | 0:e33621169e44 | 288 | * @returns the next symbol in the set, or |
hudakz | 0:e33621169e44 | 289 | * @returns NULL when no more results are available |
hudakz | 0:e33621169e44 | 290 | */ |
hudakz | 0:e33621169e44 | 291 | extern const zbar_symbol_t *zbar_symbol_next(const zbar_symbol_t *symbol); |
hudakz | 0:e33621169e44 | 292 | |
hudakz | 0:e33621169e44 | 293 | /** retrieve components of a composite result. |
hudakz | 0:e33621169e44 | 294 | * @returns the symbol set containing the components |
hudakz | 0:e33621169e44 | 295 | * @returns NULL if the symbol is already a physical symbol |
hudakz | 0:e33621169e44 | 296 | * @since 0.10 |
hudakz | 0:e33621169e44 | 297 | */ |
hudakz | 0:e33621169e44 | 298 | extern const zbar_symbol_set_t* |
hudakz | 0:e33621169e44 | 299 | zbar_symbol_get_components(const zbar_symbol_t *symbol); |
hudakz | 0:e33621169e44 | 300 | |
hudakz | 0:e33621169e44 | 301 | /** iterate components of a composite result. |
hudakz | 0:e33621169e44 | 302 | * @returns the first physical component symbol of a composite result |
hudakz | 0:e33621169e44 | 303 | * @returns NULL if the symbol is already a physical symbol |
hudakz | 0:e33621169e44 | 304 | * @since 0.10 |
hudakz | 0:e33621169e44 | 305 | */ |
hudakz | 0:e33621169e44 | 306 | extern const zbar_symbol_t* |
hudakz | 0:e33621169e44 | 307 | zbar_symbol_first_component(const zbar_symbol_t *symbol); |
hudakz | 0:e33621169e44 | 308 | |
hudakz | 0:e33621169e44 | 309 | /** print XML symbol element representation to user result buffer. |
hudakz | 0:e33621169e44 | 310 | * @see http://zbar.sourceforge.net/2008/barcode.xsd for the schema. |
hudakz | 0:e33621169e44 | 311 | * @param symbol is the symbol to print |
hudakz | 0:e33621169e44 | 312 | * @param buffer is the inout result pointer, it will be reallocated |
hudakz | 0:e33621169e44 | 313 | * with a larger size if necessary. |
hudakz | 0:e33621169e44 | 314 | * @param buflen is inout length of the result buffer. |
hudakz | 0:e33621169e44 | 315 | * @returns the buffer pointer |
hudakz | 0:e33621169e44 | 316 | * @since 0.6 |
hudakz | 0:e33621169e44 | 317 | */ |
hudakz | 0:e33621169e44 | 318 | extern char *zbar_symbol_xml(const zbar_symbol_t *symbol, |
hudakz | 0:e33621169e44 | 319 | char **buffer, |
hudakz | 0:e33621169e44 | 320 | unsigned *buflen); |
hudakz | 0:e33621169e44 | 321 | |
hudakz | 0:e33621169e44 | 322 | /*@}*/ |
hudakz | 0:e33621169e44 | 323 | |
hudakz | 0:e33621169e44 | 324 | /*------------------------------------------------------------*/ |
hudakz | 0:e33621169e44 | 325 | /** @name Symbol Set interface |
hudakz | 0:e33621169e44 | 326 | * container for decoded result symbols associated with an image |
hudakz | 0:e33621169e44 | 327 | * or a composite symbol. |
hudakz | 0:e33621169e44 | 328 | * @since 0.10 |
hudakz | 0:e33621169e44 | 329 | */ |
hudakz | 0:e33621169e44 | 330 | /*@{*/ |
hudakz | 0:e33621169e44 | 331 | |
hudakz | 0:e33621169e44 | 332 | /** @typedef zbar_symbol_set_t |
hudakz | 0:e33621169e44 | 333 | * opaque symbol iterator object. |
hudakz | 0:e33621169e44 | 334 | * @since 0.10 |
hudakz | 0:e33621169e44 | 335 | */ |
hudakz | 0:e33621169e44 | 336 | |
hudakz | 0:e33621169e44 | 337 | /** reference count manipulation. |
hudakz | 0:e33621169e44 | 338 | * increment the reference count when you store a new reference. |
hudakz | 0:e33621169e44 | 339 | * decrement when the reference is no longer used. do not refer to |
hudakz | 0:e33621169e44 | 340 | * the object any longer once references have been released. |
hudakz | 0:e33621169e44 | 341 | * @since 0.10 |
hudakz | 0:e33621169e44 | 342 | */ |
hudakz | 0:e33621169e44 | 343 | extern void zbar_symbol_set_ref(const zbar_symbol_set_t *symbols, |
hudakz | 0:e33621169e44 | 344 | int refs); |
hudakz | 0:e33621169e44 | 345 | |
hudakz | 0:e33621169e44 | 346 | /** retrieve set size. |
hudakz | 0:e33621169e44 | 347 | * @returns the number of symbols in the set. |
hudakz | 0:e33621169e44 | 348 | * @since 0.10 |
hudakz | 0:e33621169e44 | 349 | */ |
hudakz | 0:e33621169e44 | 350 | extern int zbar_symbol_set_get_size(const zbar_symbol_set_t *symbols); |
hudakz | 0:e33621169e44 | 351 | |
hudakz | 0:e33621169e44 | 352 | /** set iterator. |
hudakz | 0:e33621169e44 | 353 | * @returns the first decoded symbol result in a set |
hudakz | 0:e33621169e44 | 354 | * @returns NULL if the set is empty |
hudakz | 0:e33621169e44 | 355 | * @since 0.10 |
hudakz | 0:e33621169e44 | 356 | */ |
hudakz | 0:e33621169e44 | 357 | extern const zbar_symbol_t* |
hudakz | 0:e33621169e44 | 358 | zbar_symbol_set_first_symbol(const zbar_symbol_set_t *symbols); |
hudakz | 0:e33621169e44 | 359 | |
hudakz | 0:e33621169e44 | 360 | /*@}*/ |
hudakz | 0:e33621169e44 | 361 | |
hudakz | 0:e33621169e44 | 362 | /*------------------------------------------------------------*/ |
hudakz | 0:e33621169e44 | 363 | /** @name Image interface |
hudakz | 0:e33621169e44 | 364 | * stores image data samples along with associated format and size |
hudakz | 0:e33621169e44 | 365 | * metadata |
hudakz | 0:e33621169e44 | 366 | */ |
hudakz | 0:e33621169e44 | 367 | /*@{*/ |
hudakz | 0:e33621169e44 | 368 | |
hudakz | 0:e33621169e44 | 369 | struct zbar_image_s; |
hudakz | 0:e33621169e44 | 370 | /** opaque image object. */ |
hudakz | 0:e33621169e44 | 371 | typedef struct zbar_image_s zbar_image_t; |
hudakz | 0:e33621169e44 | 372 | |
hudakz | 0:e33621169e44 | 373 | /** cleanup handler callback function. |
hudakz | 0:e33621169e44 | 374 | * called to free sample data when an image is destroyed. |
hudakz | 0:e33621169e44 | 375 | */ |
hudakz | 0:e33621169e44 | 376 | typedef void (zbar_image_cleanup_handler_t)(zbar_image_t *image); |
hudakz | 0:e33621169e44 | 377 | |
hudakz | 0:e33621169e44 | 378 | /** data handler callback function. |
hudakz | 0:e33621169e44 | 379 | * called when decoded symbol results are available for an image |
hudakz | 0:e33621169e44 | 380 | */ |
hudakz | 0:e33621169e44 | 381 | typedef void (zbar_image_data_handler_t)(zbar_image_t *image, |
hudakz | 0:e33621169e44 | 382 | const void *userdata); |
hudakz | 0:e33621169e44 | 383 | |
hudakz | 0:e33621169e44 | 384 | /** new image constructor. |
hudakz | 0:e33621169e44 | 385 | * @returns a new image object with uninitialized data and format. |
hudakz | 0:e33621169e44 | 386 | * this image should be destroyed (using zbar_image_destroy()) as |
hudakz | 0:e33621169e44 | 387 | * soon as the application is finished with it |
hudakz | 0:e33621169e44 | 388 | */ |
hudakz | 0:e33621169e44 | 389 | extern zbar_image_t *zbar_image_create(void); |
hudakz | 0:e33621169e44 | 390 | |
hudakz | 0:e33621169e44 | 391 | /** image destructor. all images created by or returned to the |
hudakz | 0:e33621169e44 | 392 | * application should be destroyed using this function. when an image |
hudakz | 0:e33621169e44 | 393 | * is destroyed, the associated data cleanup handler will be invoked |
hudakz | 0:e33621169e44 | 394 | * if available |
hudakz | 0:e33621169e44 | 395 | * @note make no assumptions about the image or the data buffer. |
hudakz | 0:e33621169e44 | 396 | * they may not be destroyed/cleaned immediately if the library |
hudakz | 0:e33621169e44 | 397 | * is still using them. if necessary, use the cleanup handler hook |
hudakz | 0:e33621169e44 | 398 | * to keep track of image data buffers |
hudakz | 0:e33621169e44 | 399 | */ |
hudakz | 0:e33621169e44 | 400 | extern void zbar_image_destroy(zbar_image_t *image); |
hudakz | 0:e33621169e44 | 401 | |
hudakz | 0:e33621169e44 | 402 | /** image reference count manipulation. |
hudakz | 0:e33621169e44 | 403 | * increment the reference count when you store a new reference to the |
hudakz | 0:e33621169e44 | 404 | * image. decrement when the reference is no longer used. do not |
hudakz | 0:e33621169e44 | 405 | * refer to the image any longer once the count is decremented. |
hudakz | 0:e33621169e44 | 406 | * zbar_image_ref(image, -1) is the same as zbar_image_destroy(image) |
hudakz | 0:e33621169e44 | 407 | * @since 0.5 |
hudakz | 0:e33621169e44 | 408 | */ |
hudakz | 0:e33621169e44 | 409 | extern void zbar_image_ref(zbar_image_t *image, |
hudakz | 0:e33621169e44 | 410 | int refs); |
hudakz | 0:e33621169e44 | 411 | |
hudakz | 0:e33621169e44 | 412 | /** image format conversion. refer to the documentation for supported |
hudakz | 0:e33621169e44 | 413 | * image formats |
hudakz | 0:e33621169e44 | 414 | * @returns a @em new image with the sample data from the original image |
hudakz | 0:e33621169e44 | 415 | * converted to the requested format. the original image is |
hudakz | 0:e33621169e44 | 416 | * unaffected. |
hudakz | 0:e33621169e44 | 417 | * @note the converted image size may be rounded (up) due to format |
hudakz | 0:e33621169e44 | 418 | * constraints |
hudakz | 0:e33621169e44 | 419 | */ |
hudakz | 0:e33621169e44 | 420 | extern zbar_image_t *zbar_image_convert(const zbar_image_t *image, |
hudakz | 0:e33621169e44 | 421 | unsigned long format); |
hudakz | 0:e33621169e44 | 422 | |
hudakz | 0:e33621169e44 | 423 | /** image format conversion with crop/pad. |
hudakz | 0:e33621169e44 | 424 | * if the requested size is larger than the image, the last row/column |
hudakz | 0:e33621169e44 | 425 | * are duplicated to cover the difference. if the requested size is |
hudakz | 0:e33621169e44 | 426 | * smaller than the image, the extra rows/columns are dropped from the |
hudakz | 0:e33621169e44 | 427 | * right/bottom. |
hudakz | 0:e33621169e44 | 428 | * @returns a @em new image with the sample data from the original |
hudakz | 0:e33621169e44 | 429 | * image converted to the requested format and size. |
hudakz | 0:e33621169e44 | 430 | * @note the image is @em not scaled |
hudakz | 0:e33621169e44 | 431 | * @see zbar_image_convert() |
hudakz | 0:e33621169e44 | 432 | * @since 0.4 |
hudakz | 0:e33621169e44 | 433 | */ |
hudakz | 0:e33621169e44 | 434 | extern zbar_image_t *zbar_image_convert_resize(const zbar_image_t *image, |
hudakz | 0:e33621169e44 | 435 | unsigned long format, |
hudakz | 0:e33621169e44 | 436 | unsigned width, |
hudakz | 0:e33621169e44 | 437 | unsigned height); |
hudakz | 0:e33621169e44 | 438 | |
hudakz | 0:e33621169e44 | 439 | /** retrieve the image format. |
hudakz | 0:e33621169e44 | 440 | * @returns the fourcc describing the format of the image sample data |
hudakz | 0:e33621169e44 | 441 | */ |
hudakz | 0:e33621169e44 | 442 | extern unsigned long zbar_image_get_format(const zbar_image_t *image); |
hudakz | 0:e33621169e44 | 443 | |
hudakz | 0:e33621169e44 | 444 | /** retrieve a "sequence" (page/frame) number associated with this image. |
hudakz | 0:e33621169e44 | 445 | * @since 0.6 |
hudakz | 0:e33621169e44 | 446 | */ |
hudakz | 0:e33621169e44 | 447 | extern unsigned zbar_image_get_sequence(const zbar_image_t *image); |
hudakz | 0:e33621169e44 | 448 | |
hudakz | 0:e33621169e44 | 449 | /** retrieve the width of the image. |
hudakz | 0:e33621169e44 | 450 | * @returns the width in sample columns |
hudakz | 0:e33621169e44 | 451 | */ |
hudakz | 0:e33621169e44 | 452 | extern unsigned zbar_image_get_width(const zbar_image_t *image); |
hudakz | 0:e33621169e44 | 453 | |
hudakz | 0:e33621169e44 | 454 | /** retrieve the height of the image. |
hudakz | 0:e33621169e44 | 455 | * @returns the height in sample rows |
hudakz | 0:e33621169e44 | 456 | */ |
hudakz | 0:e33621169e44 | 457 | extern unsigned zbar_image_get_height(const zbar_image_t *image); |
hudakz | 0:e33621169e44 | 458 | |
hudakz | 0:e33621169e44 | 459 | /** return the image sample data. the returned data buffer is only |
hudakz | 0:e33621169e44 | 460 | * valid until zbar_image_destroy() is called |
hudakz | 0:e33621169e44 | 461 | */ |
hudakz | 0:e33621169e44 | 462 | extern const void *zbar_image_get_data(const zbar_image_t *image); |
hudakz | 0:e33621169e44 | 463 | |
hudakz | 0:e33621169e44 | 464 | /** return the size of image data. |
hudakz | 0:e33621169e44 | 465 | * @since 0.6 |
hudakz | 0:e33621169e44 | 466 | */ |
hudakz | 0:e33621169e44 | 467 | extern unsigned long zbar_image_get_data_length(const zbar_image_t *img); |
hudakz | 0:e33621169e44 | 468 | |
hudakz | 0:e33621169e44 | 469 | /** retrieve the decoded results. |
hudakz | 0:e33621169e44 | 470 | * @returns the (possibly empty) set of decoded symbols |
hudakz | 0:e33621169e44 | 471 | * @returns NULL if the image has not been scanned |
hudakz | 0:e33621169e44 | 472 | * @since 0.10 |
hudakz | 0:e33621169e44 | 473 | */ |
hudakz | 0:e33621169e44 | 474 | extern const zbar_symbol_set_t* |
hudakz | 0:e33621169e44 | 475 | zbar_image_get_symbols(const zbar_image_t *image); |
hudakz | 0:e33621169e44 | 476 | |
hudakz | 0:e33621169e44 | 477 | /** associate the specified symbol set with the image, replacing any |
hudakz | 0:e33621169e44 | 478 | * existing results. use NULL to release the current results from the |
hudakz | 0:e33621169e44 | 479 | * image. |
hudakz | 0:e33621169e44 | 480 | * @see zbar_image_scanner_recycle_image() |
hudakz | 0:e33621169e44 | 481 | * @since 0.10 |
hudakz | 0:e33621169e44 | 482 | */ |
hudakz | 0:e33621169e44 | 483 | extern void zbar_image_set_symbols(zbar_image_t *image, |
hudakz | 0:e33621169e44 | 484 | const zbar_symbol_set_t *symbols); |
hudakz | 0:e33621169e44 | 485 | |
hudakz | 0:e33621169e44 | 486 | /** image_scanner decode result iterator. |
hudakz | 0:e33621169e44 | 487 | * @returns the first decoded symbol result for an image |
hudakz | 0:e33621169e44 | 488 | * or NULL if no results are available |
hudakz | 0:e33621169e44 | 489 | */ |
hudakz | 0:e33621169e44 | 490 | extern const zbar_symbol_t* |
hudakz | 0:e33621169e44 | 491 | zbar_image_first_symbol(const zbar_image_t *image); |
hudakz | 0:e33621169e44 | 492 | |
hudakz | 0:e33621169e44 | 493 | /** specify the fourcc image format code for image sample data. |
hudakz | 0:e33621169e44 | 494 | * refer to the documentation for supported formats. |
hudakz | 0:e33621169e44 | 495 | * @note this does not convert the data! |
hudakz | 0:e33621169e44 | 496 | * (see zbar_image_convert() for that) |
hudakz | 0:e33621169e44 | 497 | */ |
hudakz | 0:e33621169e44 | 498 | extern void zbar_image_set_format(zbar_image_t *image, |
hudakz | 0:e33621169e44 | 499 | unsigned long format); |
hudakz | 0:e33621169e44 | 500 | |
hudakz | 0:e33621169e44 | 501 | /** associate a "sequence" (page/frame) number with this image. |
hudakz | 0:e33621169e44 | 502 | * @since 0.6 |
hudakz | 0:e33621169e44 | 503 | */ |
hudakz | 0:e33621169e44 | 504 | extern void zbar_image_set_sequence(zbar_image_t *image, |
hudakz | 0:e33621169e44 | 505 | unsigned sequence_num); |
hudakz | 0:e33621169e44 | 506 | |
hudakz | 0:e33621169e44 | 507 | /** specify the pixel size of the image. |
hudakz | 0:e33621169e44 | 508 | * @note this does not affect the data! |
hudakz | 0:e33621169e44 | 509 | */ |
hudakz | 0:e33621169e44 | 510 | extern void zbar_image_set_size(zbar_image_t *image, |
hudakz | 0:e33621169e44 | 511 | unsigned width, |
hudakz | 0:e33621169e44 | 512 | unsigned height); |
hudakz | 0:e33621169e44 | 513 | |
hudakz | 0:e33621169e44 | 514 | /** specify image sample data. when image data is no longer needed by |
hudakz | 0:e33621169e44 | 515 | * the library the specific data cleanup handler will be called |
hudakz | 0:e33621169e44 | 516 | * (unless NULL) |
hudakz | 0:e33621169e44 | 517 | * @note application image data will not be modified by the library |
hudakz | 0:e33621169e44 | 518 | */ |
hudakz | 0:e33621169e44 | 519 | extern void zbar_image_set_data(zbar_image_t *image, |
hudakz | 0:e33621169e44 | 520 | const void *data, |
hudakz | 0:e33621169e44 | 521 | unsigned long data_byte_length, |
hudakz | 0:e33621169e44 | 522 | zbar_image_cleanup_handler_t *cleanup_hndlr); |
hudakz | 0:e33621169e44 | 523 | |
hudakz | 0:e33621169e44 | 524 | /** built-in cleanup handler. |
hudakz | 0:e33621169e44 | 525 | * passes the image data buffer to free() |
hudakz | 0:e33621169e44 | 526 | */ |
hudakz | 0:e33621169e44 | 527 | extern void zbar_image_free_data(zbar_image_t *image); |
hudakz | 0:e33621169e44 | 528 | |
hudakz | 0:e33621169e44 | 529 | /** associate user specified data value with an image. |
hudakz | 0:e33621169e44 | 530 | * @since 0.5 |
hudakz | 0:e33621169e44 | 531 | */ |
hudakz | 0:e33621169e44 | 532 | extern void zbar_image_set_userdata(zbar_image_t *image, |
hudakz | 0:e33621169e44 | 533 | void *userdata); |
hudakz | 0:e33621169e44 | 534 | |
hudakz | 0:e33621169e44 | 535 | /** return user specified data value associated with the image. |
hudakz | 0:e33621169e44 | 536 | * @since 0.5 |
hudakz | 0:e33621169e44 | 537 | */ |
hudakz | 0:e33621169e44 | 538 | extern void *zbar_image_get_userdata(const zbar_image_t *image); |
hudakz | 0:e33621169e44 | 539 | |
hudakz | 0:e33621169e44 | 540 | /** dump raw image data to a file for debug. |
hudakz | 0:e33621169e44 | 541 | * the data will be prefixed with a 16 byte header consisting of: |
hudakz | 0:e33621169e44 | 542 | * - 4 bytes uint = 0x676d697a ("zimg") |
hudakz | 0:e33621169e44 | 543 | * - 4 bytes format fourcc |
hudakz | 0:e33621169e44 | 544 | * - 2 bytes width |
hudakz | 0:e33621169e44 | 545 | * - 2 bytes height |
hudakz | 0:e33621169e44 | 546 | * - 4 bytes size of following image data in bytes |
hudakz | 0:e33621169e44 | 547 | * this header can be dumped w/eg: |
hudakz | 0:e33621169e44 | 548 | * @verbatim |
hudakz | 0:e33621169e44 | 549 | od -Ax -tx1z -N16 -w4 [file] |
hudakz | 0:e33621169e44 | 550 | @endverbatim |
hudakz | 0:e33621169e44 | 551 | * for some formats the image can be displayed/converted using |
hudakz | 0:e33621169e44 | 552 | * ImageMagick, eg: |
hudakz | 0:e33621169e44 | 553 | * @verbatim |
hudakz | 0:e33621169e44 | 554 | display -size 640x480+16 [-depth ?] [-sampling-factor ?x?] \ |
hudakz | 0:e33621169e44 | 555 | {GRAY,RGB,UYVY,YUV}:[file] |
hudakz | 0:e33621169e44 | 556 | @endverbatim |
hudakz | 0:e33621169e44 | 557 | * |
hudakz | 0:e33621169e44 | 558 | * @param image the image object to dump |
hudakz | 0:e33621169e44 | 559 | * @param filebase base filename, appended with ".XXXX.zimg" where |
hudakz | 0:e33621169e44 | 560 | * XXXX is the format fourcc |
hudakz | 0:e33621169e44 | 561 | * @returns 0 on success or a system error code on failure |
hudakz | 0:e33621169e44 | 562 | */ |
hudakz | 0:e33621169e44 | 563 | extern int zbar_image_write(const zbar_image_t *image, |
hudakz | 0:e33621169e44 | 564 | const char *filebase); |
hudakz | 0:e33621169e44 | 565 | |
hudakz | 0:e33621169e44 | 566 | /** read back an image in the format written by zbar_image_write() |
hudakz | 0:e33621169e44 | 567 | * @note TBD |
hudakz | 0:e33621169e44 | 568 | */ |
hudakz | 0:e33621169e44 | 569 | extern zbar_image_t *zbar_image_read(char *filename); |
hudakz | 0:e33621169e44 | 570 | |
hudakz | 0:e33621169e44 | 571 | /*@}*/ |
hudakz | 0:e33621169e44 | 572 | |
hudakz | 0:e33621169e44 | 573 | /*------------------------------------------------------------*/ |
hudakz | 0:e33621169e44 | 574 | /** @name Processor interface |
hudakz | 0:e33621169e44 | 575 | * @anchor c-processor |
hudakz | 0:e33621169e44 | 576 | * high-level self-contained image processor. |
hudakz | 0:e33621169e44 | 577 | * processes video and images for barcodes, optionally displaying |
hudakz | 0:e33621169e44 | 578 | * images to a library owned output window |
hudakz | 0:e33621169e44 | 579 | */ |
hudakz | 0:e33621169e44 | 580 | /*@{*/ |
hudakz | 0:e33621169e44 | 581 | |
hudakz | 0:e33621169e44 | 582 | struct zbar_processor_s; |
hudakz | 0:e33621169e44 | 583 | /** opaque standalone processor object. */ |
hudakz | 0:e33621169e44 | 584 | typedef struct zbar_processor_s zbar_processor_t; |
hudakz | 0:e33621169e44 | 585 | |
hudakz | 0:e33621169e44 | 586 | /** constructor. |
hudakz | 0:e33621169e44 | 587 | * if threaded is set and threading is available the processor |
hudakz | 0:e33621169e44 | 588 | * will spawn threads where appropriate to avoid blocking and |
hudakz | 0:e33621169e44 | 589 | * improve responsiveness |
hudakz | 0:e33621169e44 | 590 | */ |
hudakz | 0:e33621169e44 | 591 | extern zbar_processor_t *zbar_processor_create(int threaded); |
hudakz | 0:e33621169e44 | 592 | |
hudakz | 0:e33621169e44 | 593 | /** destructor. cleans up all resources associated with the processor |
hudakz | 0:e33621169e44 | 594 | */ |
hudakz | 0:e33621169e44 | 595 | extern void zbar_processor_destroy(zbar_processor_t *processor); |
hudakz | 0:e33621169e44 | 596 | |
hudakz | 0:e33621169e44 | 597 | /** (re)initialization. |
hudakz | 0:e33621169e44 | 598 | * opens a video input device and/or prepares to display output |
hudakz | 0:e33621169e44 | 599 | */ |
hudakz | 0:e33621169e44 | 600 | extern int zbar_processor_init(zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 601 | const char *video_device, |
hudakz | 0:e33621169e44 | 602 | int enable_display); |
hudakz | 0:e33621169e44 | 603 | |
hudakz | 0:e33621169e44 | 604 | /** request a preferred size for the video image from the device. |
hudakz | 0:e33621169e44 | 605 | * the request may be adjusted or completely ignored by the driver. |
hudakz | 0:e33621169e44 | 606 | * @note must be called before zbar_processor_init() |
hudakz | 0:e33621169e44 | 607 | * @since 0.6 |
hudakz | 0:e33621169e44 | 608 | */ |
hudakz | 0:e33621169e44 | 609 | extern int zbar_processor_request_size(zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 610 | unsigned width, |
hudakz | 0:e33621169e44 | 611 | unsigned height); |
hudakz | 0:e33621169e44 | 612 | |
hudakz | 0:e33621169e44 | 613 | /** request a preferred video driver interface version for |
hudakz | 0:e33621169e44 | 614 | * debug/testing. |
hudakz | 0:e33621169e44 | 615 | * @note must be called before zbar_processor_init() |
hudakz | 0:e33621169e44 | 616 | * @since 0.6 |
hudakz | 0:e33621169e44 | 617 | */ |
hudakz | 0:e33621169e44 | 618 | extern int zbar_processor_request_interface(zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 619 | int version); |
hudakz | 0:e33621169e44 | 620 | |
hudakz | 0:e33621169e44 | 621 | /** request a preferred video I/O mode for debug/testing. You will |
hudakz | 0:e33621169e44 | 622 | * get errors if the driver does not support the specified mode. |
hudakz | 0:e33621169e44 | 623 | * @verbatim |
hudakz | 0:e33621169e44 | 624 | 0 = auto-detect |
hudakz | 0:e33621169e44 | 625 | 1 = force I/O using read() |
hudakz | 0:e33621169e44 | 626 | 2 = force memory mapped I/O using mmap() |
hudakz | 0:e33621169e44 | 627 | 3 = force USERPTR I/O (v4l2 only) |
hudakz | 0:e33621169e44 | 628 | @endverbatim |
hudakz | 0:e33621169e44 | 629 | * @note must be called before zbar_processor_init() |
hudakz | 0:e33621169e44 | 630 | * @since 0.7 |
hudakz | 0:e33621169e44 | 631 | */ |
hudakz | 0:e33621169e44 | 632 | extern int zbar_processor_request_iomode(zbar_processor_t *video, |
hudakz | 0:e33621169e44 | 633 | int iomode); |
hudakz | 0:e33621169e44 | 634 | |
hudakz | 0:e33621169e44 | 635 | /** force specific input and output formats for debug/testing. |
hudakz | 0:e33621169e44 | 636 | * @note must be called before zbar_processor_init() |
hudakz | 0:e33621169e44 | 637 | */ |
hudakz | 0:e33621169e44 | 638 | extern int zbar_processor_force_format(zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 639 | unsigned long input_format, |
hudakz | 0:e33621169e44 | 640 | unsigned long output_format); |
hudakz | 0:e33621169e44 | 641 | |
hudakz | 0:e33621169e44 | 642 | /** setup result handler callback. |
hudakz | 0:e33621169e44 | 643 | * the specified function will be called by the processor whenever |
hudakz | 0:e33621169e44 | 644 | * new results are available from the video stream or a static image. |
hudakz | 0:e33621169e44 | 645 | * pass a NULL value to disable callbacks. |
hudakz | 0:e33621169e44 | 646 | * @param processor the object on which to set the handler. |
hudakz | 0:e33621169e44 | 647 | * @param handler the function to call when new results are available. |
hudakz | 0:e33621169e44 | 648 | * @param userdata is set as with zbar_processor_set_userdata(). |
hudakz | 0:e33621169e44 | 649 | * @returns the previously registered handler |
hudakz | 0:e33621169e44 | 650 | */ |
hudakz | 0:e33621169e44 | 651 | extern zbar_image_data_handler_t* |
hudakz | 0:e33621169e44 | 652 | zbar_processor_set_data_handler(zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 653 | zbar_image_data_handler_t *handler, |
hudakz | 0:e33621169e44 | 654 | const void *userdata); |
hudakz | 0:e33621169e44 | 655 | |
hudakz | 0:e33621169e44 | 656 | /** associate user specified data value with the processor. |
hudakz | 0:e33621169e44 | 657 | * @since 0.6 |
hudakz | 0:e33621169e44 | 658 | */ |
hudakz | 0:e33621169e44 | 659 | extern void zbar_processor_set_userdata(zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 660 | void *userdata); |
hudakz | 0:e33621169e44 | 661 | |
hudakz | 0:e33621169e44 | 662 | /** return user specified data value associated with the processor. |
hudakz | 0:e33621169e44 | 663 | * @since 0.6 |
hudakz | 0:e33621169e44 | 664 | */ |
hudakz | 0:e33621169e44 | 665 | extern void *zbar_processor_get_userdata(const zbar_processor_t *processor); |
hudakz | 0:e33621169e44 | 666 | |
hudakz | 0:e33621169e44 | 667 | /** set config for indicated symbology (0 for all) to specified value. |
hudakz | 0:e33621169e44 | 668 | * @returns 0 for success, non-0 for failure (config does not apply to |
hudakz | 0:e33621169e44 | 669 | * specified symbology, or value out of range) |
hudakz | 0:e33621169e44 | 670 | * @see zbar_decoder_set_config() |
hudakz | 0:e33621169e44 | 671 | * @since 0.4 |
hudakz | 0:e33621169e44 | 672 | */ |
hudakz | 0:e33621169e44 | 673 | extern int zbar_processor_set_config(zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 674 | zbar_symbol_type_t symbology, |
hudakz | 0:e33621169e44 | 675 | zbar_config_t config, |
hudakz | 0:e33621169e44 | 676 | int value); |
hudakz | 0:e33621169e44 | 677 | |
hudakz | 0:e33621169e44 | 678 | /** parse configuration string using zbar_parse_config() |
hudakz | 0:e33621169e44 | 679 | * and apply to processor using zbar_processor_set_config(). |
hudakz | 0:e33621169e44 | 680 | * @returns 0 for success, non-0 for failure |
hudakz | 0:e33621169e44 | 681 | * @see zbar_parse_config() |
hudakz | 0:e33621169e44 | 682 | * @see zbar_processor_set_config() |
hudakz | 0:e33621169e44 | 683 | * @since 0.4 |
hudakz | 0:e33621169e44 | 684 | */ |
hudakz | 0:e33621169e44 | 685 | static inline int zbar_processor_parse_config (zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 686 | const char *config_string) |
hudakz | 0:e33621169e44 | 687 | { |
hudakz | 0:e33621169e44 | 688 | zbar_symbol_type_t sym; |
hudakz | 0:e33621169e44 | 689 | zbar_config_t cfg; |
hudakz | 0:e33621169e44 | 690 | int val; |
hudakz | 0:e33621169e44 | 691 | return(zbar_parse_config(config_string, &sym, &cfg, &val) || |
hudakz | 0:e33621169e44 | 692 | zbar_processor_set_config(processor, sym, cfg, val)); |
hudakz | 0:e33621169e44 | 693 | } |
hudakz | 0:e33621169e44 | 694 | |
hudakz | 0:e33621169e44 | 695 | /** retrieve the current state of the ouput window. |
hudakz | 0:e33621169e44 | 696 | * @returns 1 if the output window is currently displayed, 0 if not. |
hudakz | 0:e33621169e44 | 697 | * @returns -1 if an error occurs |
hudakz | 0:e33621169e44 | 698 | */ |
hudakz | 0:e33621169e44 | 699 | extern int zbar_processor_is_visible(zbar_processor_t *processor); |
hudakz | 0:e33621169e44 | 700 | |
hudakz | 0:e33621169e44 | 701 | /** show or hide the display window owned by the library. |
hudakz | 0:e33621169e44 | 702 | * the size will be adjusted to the input size |
hudakz | 0:e33621169e44 | 703 | */ |
hudakz | 0:e33621169e44 | 704 | extern int zbar_processor_set_visible(zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 705 | int visible); |
hudakz | 0:e33621169e44 | 706 | |
hudakz | 0:e33621169e44 | 707 | /** control the processor in free running video mode. |
hudakz | 0:e33621169e44 | 708 | * only works if video input is initialized. if threading is in use, |
hudakz | 0:e33621169e44 | 709 | * scanning will occur in the background, otherwise this is only |
hudakz | 0:e33621169e44 | 710 | * useful wrapping calls to zbar_processor_user_wait(). if the |
hudakz | 0:e33621169e44 | 711 | * library output window is visible, video display will be enabled. |
hudakz | 0:e33621169e44 | 712 | */ |
hudakz | 0:e33621169e44 | 713 | extern int zbar_processor_set_active(zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 714 | int active); |
hudakz | 0:e33621169e44 | 715 | |
hudakz | 0:e33621169e44 | 716 | /** retrieve decode results for last scanned image/frame. |
hudakz | 0:e33621169e44 | 717 | * @returns the symbol set result container or NULL if no results are |
hudakz | 0:e33621169e44 | 718 | * available |
hudakz | 0:e33621169e44 | 719 | * @note the returned symbol set has its reference count incremented; |
hudakz | 0:e33621169e44 | 720 | * ensure that the count is decremented after use |
hudakz | 0:e33621169e44 | 721 | * @since 0.10 |
hudakz | 0:e33621169e44 | 722 | */ |
hudakz | 0:e33621169e44 | 723 | extern const zbar_symbol_set_t* |
hudakz | 0:e33621169e44 | 724 | zbar_processor_get_results(const zbar_processor_t *processor); |
hudakz | 0:e33621169e44 | 725 | |
hudakz | 0:e33621169e44 | 726 | /** wait for input to the display window from the user |
hudakz | 0:e33621169e44 | 727 | * (via mouse or keyboard). |
hudakz | 0:e33621169e44 | 728 | * @returns >0 when input is received, 0 if timeout ms expired |
hudakz | 0:e33621169e44 | 729 | * with no input or -1 in case of an error |
hudakz | 0:e33621169e44 | 730 | */ |
hudakz | 0:e33621169e44 | 731 | extern int zbar_processor_user_wait(zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 732 | int timeout); |
hudakz | 0:e33621169e44 | 733 | |
hudakz | 0:e33621169e44 | 734 | /** process from the video stream until a result is available, |
hudakz | 0:e33621169e44 | 735 | * or the timeout (in milliseconds) expires. |
hudakz | 0:e33621169e44 | 736 | * specify a timeout of -1 to scan indefinitely |
hudakz | 0:e33621169e44 | 737 | * (zbar_processor_set_active() may still be used to abort the scan |
hudakz | 0:e33621169e44 | 738 | * from another thread). |
hudakz | 0:e33621169e44 | 739 | * if the library window is visible, video display will be enabled. |
hudakz | 0:e33621169e44 | 740 | * @note that multiple results may still be returned (despite the |
hudakz | 0:e33621169e44 | 741 | * name). |
hudakz | 0:e33621169e44 | 742 | * @returns >0 if symbols were successfully decoded, |
hudakz | 0:e33621169e44 | 743 | * 0 if no symbols were found (ie, the timeout expired) |
hudakz | 0:e33621169e44 | 744 | * or -1 if an error occurs |
hudakz | 0:e33621169e44 | 745 | */ |
hudakz | 0:e33621169e44 | 746 | extern int zbar_process_one(zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 747 | int timeout); |
hudakz | 0:e33621169e44 | 748 | |
hudakz | 0:e33621169e44 | 749 | /** process the provided image for barcodes. |
hudakz | 0:e33621169e44 | 750 | * if the library window is visible, the image will be displayed. |
hudakz | 0:e33621169e44 | 751 | * @returns >0 if symbols were successfully decoded, |
hudakz | 0:e33621169e44 | 752 | * 0 if no symbols were found or -1 if an error occurs |
hudakz | 0:e33621169e44 | 753 | */ |
hudakz | 0:e33621169e44 | 754 | extern int zbar_process_image(zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 755 | zbar_image_t *image); |
hudakz | 0:e33621169e44 | 756 | |
hudakz | 0:e33621169e44 | 757 | /** display detail for last processor error to stderr. |
hudakz | 0:e33621169e44 | 758 | * @returns a non-zero value suitable for passing to exit() |
hudakz | 0:e33621169e44 | 759 | */ |
hudakz | 0:e33621169e44 | 760 | static inline int |
hudakz | 0:e33621169e44 | 761 | zbar_processor_error_spew (const zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 762 | int verbosity) |
hudakz | 0:e33621169e44 | 763 | { |
hudakz | 0:e33621169e44 | 764 | return(_zbar_error_spew(processor, verbosity)); |
hudakz | 0:e33621169e44 | 765 | } |
hudakz | 0:e33621169e44 | 766 | |
hudakz | 0:e33621169e44 | 767 | /** retrieve the detail string for the last processor error. */ |
hudakz | 0:e33621169e44 | 768 | static inline const char* |
hudakz | 0:e33621169e44 | 769 | zbar_processor_error_string (const zbar_processor_t *processor, |
hudakz | 0:e33621169e44 | 770 | int verbosity) |
hudakz | 0:e33621169e44 | 771 | { |
hudakz | 0:e33621169e44 | 772 | return(_zbar_error_string(processor, verbosity)); |
hudakz | 0:e33621169e44 | 773 | } |
hudakz | 0:e33621169e44 | 774 | |
hudakz | 0:e33621169e44 | 775 | /** retrieve the type code for the last processor error. */ |
hudakz | 0:e33621169e44 | 776 | static inline zbar_error_t |
hudakz | 0:e33621169e44 | 777 | zbar_processor_get_error_code (const zbar_processor_t *processor) |
hudakz | 0:e33621169e44 | 778 | { |
hudakz | 0:e33621169e44 | 779 | return(_zbar_get_error_code(processor)); |
hudakz | 0:e33621169e44 | 780 | } |
hudakz | 0:e33621169e44 | 781 | |
hudakz | 0:e33621169e44 | 782 | /*@}*/ |
hudakz | 0:e33621169e44 | 783 | |
hudakz | 0:e33621169e44 | 784 | /*------------------------------------------------------------*/ |
hudakz | 0:e33621169e44 | 785 | /** @name Video interface |
hudakz | 0:e33621169e44 | 786 | * @anchor c-video |
hudakz | 0:e33621169e44 | 787 | * mid-level video source abstraction. |
hudakz | 0:e33621169e44 | 788 | * captures images from a video device |
hudakz | 0:e33621169e44 | 789 | */ |
hudakz | 0:e33621169e44 | 790 | /*@{*/ |
hudakz | 0:e33621169e44 | 791 | |
hudakz | 0:e33621169e44 | 792 | struct zbar_video_s; |
hudakz | 0:e33621169e44 | 793 | /** opaque video object. */ |
hudakz | 0:e33621169e44 | 794 | typedef struct zbar_video_s zbar_video_t; |
hudakz | 0:e33621169e44 | 795 | |
hudakz | 0:e33621169e44 | 796 | /** constructor. */ |
hudakz | 0:e33621169e44 | 797 | extern zbar_video_t *zbar_video_create(void); |
hudakz | 0:e33621169e44 | 798 | |
hudakz | 0:e33621169e44 | 799 | /** destructor. */ |
hudakz | 0:e33621169e44 | 800 | extern void zbar_video_destroy(zbar_video_t *video); |
hudakz | 0:e33621169e44 | 801 | |
hudakz | 0:e33621169e44 | 802 | /** open and probe a video device. |
hudakz | 0:e33621169e44 | 803 | * the device specified by platform specific unique name |
hudakz | 0:e33621169e44 | 804 | * (v4l device node path in *nix eg "/dev/video", |
hudakz | 0:e33621169e44 | 805 | * DirectShow DevicePath property in windows). |
hudakz | 0:e33621169e44 | 806 | * @returns 0 if successful or -1 if an error occurs |
hudakz | 0:e33621169e44 | 807 | */ |
hudakz | 0:e33621169e44 | 808 | extern int zbar_video_open(zbar_video_t *video, |
hudakz | 0:e33621169e44 | 809 | const char *device); |
hudakz | 0:e33621169e44 | 810 | |
hudakz | 0:e33621169e44 | 811 | /** retrieve file descriptor associated with open *nix video device |
hudakz | 0:e33621169e44 | 812 | * useful for using select()/poll() to tell when new images are |
hudakz | 0:e33621169e44 | 813 | * available (NB v4l2 only!!). |
hudakz | 0:e33621169e44 | 814 | * @returns the file descriptor or -1 if the video device is not open |
hudakz | 0:e33621169e44 | 815 | * or the driver only supports v4l1 |
hudakz | 0:e33621169e44 | 816 | */ |
hudakz | 0:e33621169e44 | 817 | extern int zbar_video_get_fd(const zbar_video_t *video); |
hudakz | 0:e33621169e44 | 818 | |
hudakz | 0:e33621169e44 | 819 | /** request a preferred size for the video image from the device. |
hudakz | 0:e33621169e44 | 820 | * the request may be adjusted or completely ignored by the driver. |
hudakz | 0:e33621169e44 | 821 | * @returns 0 if successful or -1 if the video device is already |
hudakz | 0:e33621169e44 | 822 | * initialized |
hudakz | 0:e33621169e44 | 823 | * @since 0.6 |
hudakz | 0:e33621169e44 | 824 | */ |
hudakz | 0:e33621169e44 | 825 | extern int zbar_video_request_size(zbar_video_t *video, |
hudakz | 0:e33621169e44 | 826 | unsigned width, |
hudakz | 0:e33621169e44 | 827 | unsigned height); |
hudakz | 0:e33621169e44 | 828 | |
hudakz | 0:e33621169e44 | 829 | /** request a preferred driver interface version for debug/testing. |
hudakz | 0:e33621169e44 | 830 | * @note must be called before zbar_video_open() |
hudakz | 0:e33621169e44 | 831 | * @since 0.6 |
hudakz | 0:e33621169e44 | 832 | */ |
hudakz | 0:e33621169e44 | 833 | extern int zbar_video_request_interface(zbar_video_t *video, |
hudakz | 0:e33621169e44 | 834 | int version); |
hudakz | 0:e33621169e44 | 835 | |
hudakz | 0:e33621169e44 | 836 | /** request a preferred I/O mode for debug/testing. You will get |
hudakz | 0:e33621169e44 | 837 | * errors if the driver does not support the specified mode. |
hudakz | 0:e33621169e44 | 838 | * @verbatim |
hudakz | 0:e33621169e44 | 839 | 0 = auto-detect |
hudakz | 0:e33621169e44 | 840 | 1 = force I/O using read() |
hudakz | 0:e33621169e44 | 841 | 2 = force memory mapped I/O using mmap() |
hudakz | 0:e33621169e44 | 842 | 3 = force USERPTR I/O (v4l2 only) |
hudakz | 0:e33621169e44 | 843 | @endverbatim |
hudakz | 0:e33621169e44 | 844 | * @note must be called before zbar_video_open() |
hudakz | 0:e33621169e44 | 845 | * @since 0.7 |
hudakz | 0:e33621169e44 | 846 | */ |
hudakz | 0:e33621169e44 | 847 | extern int zbar_video_request_iomode(zbar_video_t *video, |
hudakz | 0:e33621169e44 | 848 | int iomode); |
hudakz | 0:e33621169e44 | 849 | |
hudakz | 0:e33621169e44 | 850 | /** retrieve current output image width. |
hudakz | 0:e33621169e44 | 851 | * @returns the width or 0 if the video device is not open |
hudakz | 0:e33621169e44 | 852 | */ |
hudakz | 0:e33621169e44 | 853 | extern int zbar_video_get_width(const zbar_video_t *video); |
hudakz | 0:e33621169e44 | 854 | |
hudakz | 0:e33621169e44 | 855 | /** retrieve current output image height. |
hudakz | 0:e33621169e44 | 856 | * @returns the height or 0 if the video device is not open |
hudakz | 0:e33621169e44 | 857 | */ |
hudakz | 0:e33621169e44 | 858 | extern int zbar_video_get_height(const zbar_video_t *video); |
hudakz | 0:e33621169e44 | 859 | |
hudakz | 0:e33621169e44 | 860 | /** initialize video using a specific format for debug. |
hudakz | 0:e33621169e44 | 861 | * use zbar_negotiate_format() to automatically select and initialize |
hudakz | 0:e33621169e44 | 862 | * the best available format |
hudakz | 0:e33621169e44 | 863 | */ |
hudakz | 0:e33621169e44 | 864 | extern int zbar_video_init(zbar_video_t *video, |
hudakz | 0:e33621169e44 | 865 | unsigned long format); |
hudakz | 0:e33621169e44 | 866 | |
hudakz | 0:e33621169e44 | 867 | /** start/stop video capture. |
hudakz | 0:e33621169e44 | 868 | * all buffered images are retired when capture is disabled. |
hudakz | 0:e33621169e44 | 869 | * @returns 0 if successful or -1 if an error occurs |
hudakz | 0:e33621169e44 | 870 | */ |
hudakz | 0:e33621169e44 | 871 | extern int zbar_video_enable(zbar_video_t *video, |
hudakz | 0:e33621169e44 | 872 | int enable); |
hudakz | 0:e33621169e44 | 873 | |
hudakz | 0:e33621169e44 | 874 | /** retrieve next captured image. blocks until an image is available. |
hudakz | 0:e33621169e44 | 875 | * @returns NULL if video is not enabled or an error occurs |
hudakz | 0:e33621169e44 | 876 | */ |
hudakz | 0:e33621169e44 | 877 | extern zbar_image_t *zbar_video_next_image(zbar_video_t *video); |
hudakz | 0:e33621169e44 | 878 | |
hudakz | 0:e33621169e44 | 879 | /** display detail for last video error to stderr. |
hudakz | 0:e33621169e44 | 880 | * @returns a non-zero value suitable for passing to exit() |
hudakz | 0:e33621169e44 | 881 | */ |
hudakz | 0:e33621169e44 | 882 | static inline int zbar_video_error_spew (const zbar_video_t *video, |
hudakz | 0:e33621169e44 | 883 | int verbosity) |
hudakz | 0:e33621169e44 | 884 | { |
hudakz | 0:e33621169e44 | 885 | return(_zbar_error_spew(video, verbosity)); |
hudakz | 0:e33621169e44 | 886 | } |
hudakz | 0:e33621169e44 | 887 | |
hudakz | 0:e33621169e44 | 888 | /** retrieve the detail string for the last video error. */ |
hudakz | 0:e33621169e44 | 889 | static inline const char *zbar_video_error_string (const zbar_video_t *video, |
hudakz | 0:e33621169e44 | 890 | int verbosity) |
hudakz | 0:e33621169e44 | 891 | { |
hudakz | 0:e33621169e44 | 892 | return(_zbar_error_string(video, verbosity)); |
hudakz | 0:e33621169e44 | 893 | } |
hudakz | 0:e33621169e44 | 894 | |
hudakz | 0:e33621169e44 | 895 | /** retrieve the type code for the last video error. */ |
hudakz | 0:e33621169e44 | 896 | static inline zbar_error_t |
hudakz | 0:e33621169e44 | 897 | zbar_video_get_error_code (const zbar_video_t *video) |
hudakz | 0:e33621169e44 | 898 | { |
hudakz | 0:e33621169e44 | 899 | return(_zbar_get_error_code(video)); |
hudakz | 0:e33621169e44 | 900 | } |
hudakz | 0:e33621169e44 | 901 | |
hudakz | 0:e33621169e44 | 902 | /*@}*/ |
hudakz | 0:e33621169e44 | 903 | |
hudakz | 0:e33621169e44 | 904 | /*------------------------------------------------------------*/ |
hudakz | 0:e33621169e44 | 905 | /** @name Window interface |
hudakz | 0:e33621169e44 | 906 | * @anchor c-window |
hudakz | 0:e33621169e44 | 907 | * mid-level output window abstraction. |
hudakz | 0:e33621169e44 | 908 | * displays images to user-specified platform specific output window |
hudakz | 0:e33621169e44 | 909 | */ |
hudakz | 0:e33621169e44 | 910 | /*@{*/ |
hudakz | 0:e33621169e44 | 911 | |
hudakz | 0:e33621169e44 | 912 | struct zbar_window_s; |
hudakz | 0:e33621169e44 | 913 | /** opaque window object. */ |
hudakz | 0:e33621169e44 | 914 | typedef struct zbar_window_s zbar_window_t; |
hudakz | 0:e33621169e44 | 915 | |
hudakz | 0:e33621169e44 | 916 | /** constructor. */ |
hudakz | 0:e33621169e44 | 917 | extern zbar_window_t *zbar_window_create(void); |
hudakz | 0:e33621169e44 | 918 | |
hudakz | 0:e33621169e44 | 919 | /** destructor. */ |
hudakz | 0:e33621169e44 | 920 | extern void zbar_window_destroy(zbar_window_t *window); |
hudakz | 0:e33621169e44 | 921 | |
hudakz | 0:e33621169e44 | 922 | /** associate reader with an existing platform window. |
hudakz | 0:e33621169e44 | 923 | * This can be any "Drawable" for X Windows or a "HWND" for windows. |
hudakz | 0:e33621169e44 | 924 | * input images will be scaled into the output window. |
hudakz | 0:e33621169e44 | 925 | * pass NULL to detach from the resource, further input will be |
hudakz | 0:e33621169e44 | 926 | * ignored |
hudakz | 0:e33621169e44 | 927 | */ |
hudakz | 0:e33621169e44 | 928 | extern int zbar_window_attach(zbar_window_t *window, |
hudakz | 0:e33621169e44 | 929 | void *x11_display_w32_hwnd, |
hudakz | 0:e33621169e44 | 930 | unsigned long x11_drawable); |
hudakz | 0:e33621169e44 | 931 | |
hudakz | 0:e33621169e44 | 932 | /** control content level of the reader overlay. |
hudakz | 0:e33621169e44 | 933 | * the overlay displays graphical data for informational or debug |
hudakz | 0:e33621169e44 | 934 | * purposes. higher values increase the level of annotation (possibly |
hudakz | 0:e33621169e44 | 935 | * decreasing performance). @verbatim |
hudakz | 0:e33621169e44 | 936 | 0 = disable overlay |
hudakz | 0:e33621169e44 | 937 | 1 = outline decoded symbols (default) |
hudakz | 0:e33621169e44 | 938 | 2 = also track and display input frame rate |
hudakz | 0:e33621169e44 | 939 | @endverbatim |
hudakz | 0:e33621169e44 | 940 | */ |
hudakz | 0:e33621169e44 | 941 | extern void zbar_window_set_overlay(zbar_window_t *window, |
hudakz | 0:e33621169e44 | 942 | int level); |
hudakz | 0:e33621169e44 | 943 | |
hudakz | 0:e33621169e44 | 944 | /** retrieve current content level of reader overlay. |
hudakz | 0:e33621169e44 | 945 | * @see zbar_window_set_overlay() |
hudakz | 0:e33621169e44 | 946 | * @since 0.10 |
hudakz | 0:e33621169e44 | 947 | */ |
hudakz | 0:e33621169e44 | 948 | extern int zbar_window_get_overlay(const zbar_window_t *window); |
hudakz | 0:e33621169e44 | 949 | |
hudakz | 0:e33621169e44 | 950 | /** draw a new image into the output window. */ |
hudakz | 0:e33621169e44 | 951 | extern int zbar_window_draw(zbar_window_t *window, |
hudakz | 0:e33621169e44 | 952 | zbar_image_t *image); |
hudakz | 0:e33621169e44 | 953 | |
hudakz | 0:e33621169e44 | 954 | /** redraw the last image (exposure handler). */ |
hudakz | 0:e33621169e44 | 955 | extern int zbar_window_redraw(zbar_window_t *window); |
hudakz | 0:e33621169e44 | 956 | |
hudakz | 0:e33621169e44 | 957 | /** resize the image window (reconfigure handler). |
hudakz | 0:e33621169e44 | 958 | * this does @em not update the contents of the window |
hudakz | 0:e33621169e44 | 959 | * @since 0.3, changed in 0.4 to not redraw window |
hudakz | 0:e33621169e44 | 960 | */ |
hudakz | 0:e33621169e44 | 961 | extern int zbar_window_resize(zbar_window_t *window, |
hudakz | 0:e33621169e44 | 962 | unsigned width, |
hudakz | 0:e33621169e44 | 963 | unsigned height); |
hudakz | 0:e33621169e44 | 964 | |
hudakz | 0:e33621169e44 | 965 | /** display detail for last window error to stderr. |
hudakz | 0:e33621169e44 | 966 | * @returns a non-zero value suitable for passing to exit() |
hudakz | 0:e33621169e44 | 967 | */ |
hudakz | 0:e33621169e44 | 968 | static inline int zbar_window_error_spew (const zbar_window_t *window, |
hudakz | 0:e33621169e44 | 969 | int verbosity) |
hudakz | 0:e33621169e44 | 970 | { |
hudakz | 0:e33621169e44 | 971 | return(_zbar_error_spew(window, verbosity)); |
hudakz | 0:e33621169e44 | 972 | } |
hudakz | 0:e33621169e44 | 973 | |
hudakz | 0:e33621169e44 | 974 | /** retrieve the detail string for the last window error. */ |
hudakz | 0:e33621169e44 | 975 | static inline const char* |
hudakz | 0:e33621169e44 | 976 | zbar_window_error_string (const zbar_window_t *window, |
hudakz | 0:e33621169e44 | 977 | int verbosity) |
hudakz | 0:e33621169e44 | 978 | { |
hudakz | 0:e33621169e44 | 979 | return(_zbar_error_string(window, verbosity)); |
hudakz | 0:e33621169e44 | 980 | } |
hudakz | 0:e33621169e44 | 981 | |
hudakz | 0:e33621169e44 | 982 | /** retrieve the type code for the last window error. */ |
hudakz | 0:e33621169e44 | 983 | static inline zbar_error_t |
hudakz | 0:e33621169e44 | 984 | zbar_window_get_error_code (const zbar_window_t *window) |
hudakz | 0:e33621169e44 | 985 | { |
hudakz | 0:e33621169e44 | 986 | return(_zbar_get_error_code(window)); |
hudakz | 0:e33621169e44 | 987 | } |
hudakz | 0:e33621169e44 | 988 | |
hudakz | 0:e33621169e44 | 989 | |
hudakz | 0:e33621169e44 | 990 | /** select a compatible format between video input and output window. |
hudakz | 0:e33621169e44 | 991 | * the selection algorithm attempts to use a format shared by |
hudakz | 0:e33621169e44 | 992 | * video input and window output which is also most useful for |
hudakz | 0:e33621169e44 | 993 | * barcode scanning. if a format conversion is necessary, it will |
hudakz | 0:e33621169e44 | 994 | * heuristically attempt to minimize the cost of the conversion |
hudakz | 0:e33621169e44 | 995 | */ |
hudakz | 0:e33621169e44 | 996 | extern int zbar_negotiate_format(zbar_video_t *video, |
hudakz | 0:e33621169e44 | 997 | zbar_window_t *window); |
hudakz | 0:e33621169e44 | 998 | |
hudakz | 0:e33621169e44 | 999 | /*@}*/ |
hudakz | 0:e33621169e44 | 1000 | |
hudakz | 0:e33621169e44 | 1001 | /*------------------------------------------------------------*/ |
hudakz | 0:e33621169e44 | 1002 | /** @name Image Scanner interface |
hudakz | 0:e33621169e44 | 1003 | * @anchor c-imagescanner |
hudakz | 0:e33621169e44 | 1004 | * mid-level image scanner interface. |
hudakz | 0:e33621169e44 | 1005 | * reads barcodes from 2-D images |
hudakz | 0:e33621169e44 | 1006 | */ |
hudakz | 0:e33621169e44 | 1007 | /*@{*/ |
hudakz | 0:e33621169e44 | 1008 | |
hudakz | 0:e33621169e44 | 1009 | struct zbar_image_scanner_s; |
hudakz | 0:e33621169e44 | 1010 | /** opaque image scanner object. */ |
hudakz | 0:e33621169e44 | 1011 | typedef struct zbar_image_scanner_s zbar_image_scanner_t; |
hudakz | 0:e33621169e44 | 1012 | |
hudakz | 0:e33621169e44 | 1013 | /** constructor. */ |
hudakz | 0:e33621169e44 | 1014 | extern zbar_image_scanner_t *zbar_image_scanner_create(void); |
hudakz | 0:e33621169e44 | 1015 | |
hudakz | 0:e33621169e44 | 1016 | /** destructor. */ |
hudakz | 0:e33621169e44 | 1017 | extern void zbar_image_scanner_destroy(zbar_image_scanner_t *scanner); |
hudakz | 0:e33621169e44 | 1018 | |
hudakz | 0:e33621169e44 | 1019 | /** setup result handler callback. |
hudakz | 0:e33621169e44 | 1020 | * the specified function will be called by the scanner whenever |
hudakz | 0:e33621169e44 | 1021 | * new results are available from a decoded image. |
hudakz | 0:e33621169e44 | 1022 | * pass a NULL value to disable callbacks. |
hudakz | 0:e33621169e44 | 1023 | * @returns the previously registered handler |
hudakz | 0:e33621169e44 | 1024 | */ |
hudakz | 0:e33621169e44 | 1025 | extern zbar_image_data_handler_t* |
hudakz | 0:e33621169e44 | 1026 | zbar_image_scanner_set_data_handler(zbar_image_scanner_t *scanner, |
hudakz | 0:e33621169e44 | 1027 | zbar_image_data_handler_t *handler, |
hudakz | 0:e33621169e44 | 1028 | const void *userdata); |
hudakz | 0:e33621169e44 | 1029 | |
hudakz | 0:e33621169e44 | 1030 | |
hudakz | 0:e33621169e44 | 1031 | /** set config for indicated symbology (0 for all) to specified value. |
hudakz | 0:e33621169e44 | 1032 | * @returns 0 for success, non-0 for failure (config does not apply to |
hudakz | 0:e33621169e44 | 1033 | * specified symbology, or value out of range) |
hudakz | 0:e33621169e44 | 1034 | * @see zbar_decoder_set_config() |
hudakz | 0:e33621169e44 | 1035 | * @since 0.4 |
hudakz | 0:e33621169e44 | 1036 | */ |
hudakz | 0:e33621169e44 | 1037 | extern int zbar_image_scanner_set_config(zbar_image_scanner_t *scanner, |
hudakz | 0:e33621169e44 | 1038 | zbar_symbol_type_t symbology, |
hudakz | 0:e33621169e44 | 1039 | zbar_config_t config, |
hudakz | 0:e33621169e44 | 1040 | int value); |
hudakz | 0:e33621169e44 | 1041 | |
hudakz | 0:e33621169e44 | 1042 | /** parse configuration string using zbar_parse_config() |
hudakz | 0:e33621169e44 | 1043 | * and apply to image scanner using zbar_image_scanner_set_config(). |
hudakz | 0:e33621169e44 | 1044 | * @returns 0 for success, non-0 for failure |
hudakz | 0:e33621169e44 | 1045 | * @see zbar_parse_config() |
hudakz | 0:e33621169e44 | 1046 | * @see zbar_image_scanner_set_config() |
hudakz | 0:e33621169e44 | 1047 | * @since 0.4 |
hudakz | 0:e33621169e44 | 1048 | */ |
hudakz | 0:e33621169e44 | 1049 | static inline int |
hudakz | 0:e33621169e44 | 1050 | zbar_image_scanner_parse_config (zbar_image_scanner_t *scanner, |
hudakz | 0:e33621169e44 | 1051 | const char *config_string) |
hudakz | 0:e33621169e44 | 1052 | { |
hudakz | 0:e33621169e44 | 1053 | zbar_symbol_type_t sym; |
hudakz | 0:e33621169e44 | 1054 | zbar_config_t cfg; |
hudakz | 0:e33621169e44 | 1055 | int val; |
hudakz | 0:e33621169e44 | 1056 | return(zbar_parse_config(config_string, &sym, &cfg, &val) || |
hudakz | 0:e33621169e44 | 1057 | zbar_image_scanner_set_config(scanner, sym, cfg, val)); |
hudakz | 0:e33621169e44 | 1058 | } |
hudakz | 0:e33621169e44 | 1059 | |
hudakz | 0:e33621169e44 | 1060 | /** enable or disable the inter-image result cache (default disabled). |
hudakz | 0:e33621169e44 | 1061 | * mostly useful for scanning video frames, the cache filters |
hudakz | 0:e33621169e44 | 1062 | * duplicate results from consecutive images, while adding some |
hudakz | 0:e33621169e44 | 1063 | * consistency checking and hysteresis to the results. |
hudakz | 0:e33621169e44 | 1064 | * this interface also clears the cache |
hudakz | 0:e33621169e44 | 1065 | */ |
hudakz | 0:e33621169e44 | 1066 | extern void zbar_image_scanner_enable_cache(zbar_image_scanner_t *scanner, |
hudakz | 0:e33621169e44 | 1067 | int enable); |
hudakz | 0:e33621169e44 | 1068 | |
hudakz | 0:e33621169e44 | 1069 | /** remove any previously decoded results from the image scanner and the |
hudakz | 0:e33621169e44 | 1070 | * specified image. somewhat more efficient version of |
hudakz | 0:e33621169e44 | 1071 | * zbar_image_set_symbols(image, NULL) which may retain memory for |
hudakz | 0:e33621169e44 | 1072 | * subsequent decodes |
hudakz | 0:e33621169e44 | 1073 | * @since 0.10 |
hudakz | 0:e33621169e44 | 1074 | */ |
hudakz | 0:e33621169e44 | 1075 | extern void zbar_image_scanner_recycle_image(zbar_image_scanner_t *scanner, |
hudakz | 0:e33621169e44 | 1076 | zbar_image_t *image); |
hudakz | 0:e33621169e44 | 1077 | |
hudakz | 0:e33621169e44 | 1078 | /** retrieve decode results for last scanned image. |
hudakz | 0:e33621169e44 | 1079 | * @returns the symbol set result container or NULL if no results are |
hudakz | 0:e33621169e44 | 1080 | * available |
hudakz | 0:e33621169e44 | 1081 | * @note the symbol set does not have its reference count adjusted; |
hudakz | 0:e33621169e44 | 1082 | * ensure that the count is incremented if the results may be kept |
hudakz | 0:e33621169e44 | 1083 | * after the next image is scanned |
hudakz | 0:e33621169e44 | 1084 | * @since 0.10 |
hudakz | 0:e33621169e44 | 1085 | */ |
hudakz | 0:e33621169e44 | 1086 | extern const zbar_symbol_set_t* |
hudakz | 0:e33621169e44 | 1087 | zbar_image_scanner_get_results(const zbar_image_scanner_t *scanner); |
hudakz | 0:e33621169e44 | 1088 | |
hudakz | 0:e33621169e44 | 1089 | /** scan for symbols in provided image. The image format must be |
hudakz | 0:e33621169e44 | 1090 | * "Y800" or "GRAY". |
hudakz | 0:e33621169e44 | 1091 | * @returns >0 if symbols were successfully decoded from the image, |
hudakz | 0:e33621169e44 | 1092 | * 0 if no symbols were found or -1 if an error occurs |
hudakz | 0:e33621169e44 | 1093 | * @see zbar_image_convert() |
hudakz | 0:e33621169e44 | 1094 | * @since 0.9 - changed to only accept grayscale images |
hudakz | 0:e33621169e44 | 1095 | */ |
hudakz | 0:e33621169e44 | 1096 | extern int zbar_scan_image(zbar_image_scanner_t *scanner, |
hudakz | 0:e33621169e44 | 1097 | zbar_image_t *image); |
hudakz | 0:e33621169e44 | 1098 | |
hudakz | 0:e33621169e44 | 1099 | /*@}*/ |
hudakz | 0:e33621169e44 | 1100 | |
hudakz | 0:e33621169e44 | 1101 | /*------------------------------------------------------------*/ |
hudakz | 0:e33621169e44 | 1102 | /** @name Decoder interface |
hudakz | 0:e33621169e44 | 1103 | * @anchor c-decoder |
hudakz | 0:e33621169e44 | 1104 | * low-level bar width stream decoder interface. |
hudakz | 0:e33621169e44 | 1105 | * identifies symbols and extracts encoded data |
hudakz | 0:e33621169e44 | 1106 | */ |
hudakz | 0:e33621169e44 | 1107 | /*@{*/ |
hudakz | 0:e33621169e44 | 1108 | |
hudakz | 0:e33621169e44 | 1109 | struct zbar_decoder_s; |
hudakz | 0:e33621169e44 | 1110 | /** opaque decoder object. */ |
hudakz | 0:e33621169e44 | 1111 | typedef struct zbar_decoder_s zbar_decoder_t; |
hudakz | 0:e33621169e44 | 1112 | |
hudakz | 0:e33621169e44 | 1113 | /** decoder data handler callback function. |
hudakz | 0:e33621169e44 | 1114 | * called by decoder when new data has just been decoded |
hudakz | 0:e33621169e44 | 1115 | */ |
hudakz | 0:e33621169e44 | 1116 | typedef void (zbar_decoder_handler_t)(zbar_decoder_t *decoder); |
hudakz | 0:e33621169e44 | 1117 | |
hudakz | 0:e33621169e44 | 1118 | /** constructor. */ |
hudakz | 0:e33621169e44 | 1119 | extern zbar_decoder_t *zbar_decoder_create(void); |
hudakz | 0:e33621169e44 | 1120 | |
hudakz | 0:e33621169e44 | 1121 | /** destructor. */ |
hudakz | 0:e33621169e44 | 1122 | extern void zbar_decoder_destroy(zbar_decoder_t *decoder); |
hudakz | 0:e33621169e44 | 1123 | |
hudakz | 0:e33621169e44 | 1124 | /** set config for indicated symbology (0 for all) to specified value. |
hudakz | 0:e33621169e44 | 1125 | * @returns 0 for success, non-0 for failure (config does not apply to |
hudakz | 0:e33621169e44 | 1126 | * specified symbology, or value out of range) |
hudakz | 0:e33621169e44 | 1127 | * @since 0.4 |
hudakz | 0:e33621169e44 | 1128 | */ |
hudakz | 0:e33621169e44 | 1129 | extern int zbar_decoder_set_config(zbar_decoder_t *decoder, |
hudakz | 0:e33621169e44 | 1130 | zbar_symbol_type_t symbology, |
hudakz | 0:e33621169e44 | 1131 | zbar_config_t config, |
hudakz | 0:e33621169e44 | 1132 | int value); |
hudakz | 0:e33621169e44 | 1133 | |
hudakz | 0:e33621169e44 | 1134 | /** parse configuration string using zbar_parse_config() |
hudakz | 0:e33621169e44 | 1135 | * and apply to decoder using zbar_decoder_set_config(). |
hudakz | 0:e33621169e44 | 1136 | * @returns 0 for success, non-0 for failure |
hudakz | 0:e33621169e44 | 1137 | * @see zbar_parse_config() |
hudakz | 0:e33621169e44 | 1138 | * @see zbar_decoder_set_config() |
hudakz | 0:e33621169e44 | 1139 | * @since 0.4 |
hudakz | 0:e33621169e44 | 1140 | */ |
hudakz | 0:e33621169e44 | 1141 | static inline int zbar_decoder_parse_config (zbar_decoder_t *decoder, |
hudakz | 0:e33621169e44 | 1142 | const char *config_string) |
hudakz | 0:e33621169e44 | 1143 | { |
hudakz | 0:e33621169e44 | 1144 | zbar_symbol_type_t sym; |
hudakz | 0:e33621169e44 | 1145 | zbar_config_t cfg; |
hudakz | 0:e33621169e44 | 1146 | int val; |
hudakz | 0:e33621169e44 | 1147 | return(zbar_parse_config(config_string, &sym, &cfg, &val) || |
hudakz | 0:e33621169e44 | 1148 | zbar_decoder_set_config(decoder, sym, cfg, val)); |
hudakz | 0:e33621169e44 | 1149 | } |
hudakz | 0:e33621169e44 | 1150 | |
hudakz | 0:e33621169e44 | 1151 | /** clear all decoder state. |
hudakz | 0:e33621169e44 | 1152 | * any partial symbols are flushed |
hudakz | 0:e33621169e44 | 1153 | */ |
hudakz | 0:e33621169e44 | 1154 | extern void zbar_decoder_reset(zbar_decoder_t *decoder); |
hudakz | 0:e33621169e44 | 1155 | |
hudakz | 0:e33621169e44 | 1156 | /** mark start of a new scan pass. |
hudakz | 0:e33621169e44 | 1157 | * clears any intra-symbol state and resets color to ::ZBAR_SPACE. |
hudakz | 0:e33621169e44 | 1158 | * any partially decoded symbol state is retained |
hudakz | 0:e33621169e44 | 1159 | */ |
hudakz | 0:e33621169e44 | 1160 | extern void zbar_decoder_new_scan(zbar_decoder_t *decoder); |
hudakz | 0:e33621169e44 | 1161 | |
hudakz | 0:e33621169e44 | 1162 | /** process next bar/space width from input stream. |
hudakz | 0:e33621169e44 | 1163 | * the width is in arbitrary relative units. first value of a scan |
hudakz | 0:e33621169e44 | 1164 | * is ::ZBAR_SPACE width, alternating from there. |
hudakz | 0:e33621169e44 | 1165 | * @returns appropriate symbol type if width completes |
hudakz | 0:e33621169e44 | 1166 | * decode of a symbol (data is available for retrieval) |
hudakz | 0:e33621169e44 | 1167 | * @returns ::ZBAR_PARTIAL as a hint if part of a symbol was decoded |
hudakz | 0:e33621169e44 | 1168 | * @returns ::ZBAR_NONE (0) if no new symbol data is available |
hudakz | 0:e33621169e44 | 1169 | */ |
hudakz | 0:e33621169e44 | 1170 | extern zbar_symbol_type_t zbar_decode_width(zbar_decoder_t *decoder, |
hudakz | 0:e33621169e44 | 1171 | unsigned width); |
hudakz | 0:e33621169e44 | 1172 | |
hudakz | 0:e33621169e44 | 1173 | /** retrieve color of @em next element passed to |
hudakz | 0:e33621169e44 | 1174 | * zbar_decode_width(). */ |
hudakz | 0:e33621169e44 | 1175 | extern zbar_color_t zbar_decoder_get_color(const zbar_decoder_t *decoder); |
hudakz | 0:e33621169e44 | 1176 | |
hudakz | 0:e33621169e44 | 1177 | /** retrieve last decoded data. |
hudakz | 0:e33621169e44 | 1178 | * @returns the data string or NULL if no new data available. |
hudakz | 0:e33621169e44 | 1179 | * the returned data buffer is owned by library, contents are only |
hudakz | 0:e33621169e44 | 1180 | * valid between non-0 return from zbar_decode_width and next library |
hudakz | 0:e33621169e44 | 1181 | * call |
hudakz | 0:e33621169e44 | 1182 | */ |
hudakz | 0:e33621169e44 | 1183 | extern const char *zbar_decoder_get_data(const zbar_decoder_t *decoder); |
hudakz | 0:e33621169e44 | 1184 | |
hudakz | 0:e33621169e44 | 1185 | /** retrieve length of binary data. |
hudakz | 0:e33621169e44 | 1186 | * @returns the length of the decoded data or 0 if no new data |
hudakz | 0:e33621169e44 | 1187 | * available. |
hudakz | 0:e33621169e44 | 1188 | */ |
hudakz | 0:e33621169e44 | 1189 | extern unsigned int |
hudakz | 0:e33621169e44 | 1190 | zbar_decoder_get_data_length(const zbar_decoder_t *decoder); |
hudakz | 0:e33621169e44 | 1191 | |
hudakz | 0:e33621169e44 | 1192 | /** retrieve last decoded symbol type. |
hudakz | 0:e33621169e44 | 1193 | * @returns the type or ::ZBAR_NONE if no new data available |
hudakz | 0:e33621169e44 | 1194 | */ |
hudakz | 0:e33621169e44 | 1195 | extern zbar_symbol_type_t |
hudakz | 0:e33621169e44 | 1196 | zbar_decoder_get_type(const zbar_decoder_t *decoder); |
hudakz | 0:e33621169e44 | 1197 | |
hudakz | 0:e33621169e44 | 1198 | /** setup data handler callback. |
hudakz | 0:e33621169e44 | 1199 | * the registered function will be called by the decoder |
hudakz | 0:e33621169e44 | 1200 | * just before zbar_decode_width() returns a non-zero value. |
hudakz | 0:e33621169e44 | 1201 | * pass a NULL value to disable callbacks. |
hudakz | 0:e33621169e44 | 1202 | * @returns the previously registered handler |
hudakz | 0:e33621169e44 | 1203 | */ |
hudakz | 0:e33621169e44 | 1204 | extern zbar_decoder_handler_t* |
hudakz | 0:e33621169e44 | 1205 | zbar_decoder_set_handler(zbar_decoder_t *decoder, |
hudakz | 0:e33621169e44 | 1206 | zbar_decoder_handler_t *handler); |
hudakz | 0:e33621169e44 | 1207 | |
hudakz | 0:e33621169e44 | 1208 | /** associate user specified data value with the decoder. */ |
hudakz | 0:e33621169e44 | 1209 | extern void zbar_decoder_set_userdata(zbar_decoder_t *decoder, |
hudakz | 0:e33621169e44 | 1210 | void *userdata); |
hudakz | 0:e33621169e44 | 1211 | |
hudakz | 0:e33621169e44 | 1212 | /** return user specified data value associated with the decoder. */ |
hudakz | 0:e33621169e44 | 1213 | extern void *zbar_decoder_get_userdata(const zbar_decoder_t *decoder); |
hudakz | 0:e33621169e44 | 1214 | |
hudakz | 0:e33621169e44 | 1215 | /*@}*/ |
hudakz | 0:e33621169e44 | 1216 | |
hudakz | 0:e33621169e44 | 1217 | /*------------------------------------------------------------*/ |
hudakz | 0:e33621169e44 | 1218 | /** @name Scanner interface |
hudakz | 0:e33621169e44 | 1219 | * @anchor c-scanner |
hudakz | 0:e33621169e44 | 1220 | * low-level linear intensity sample stream scanner interface. |
hudakz | 0:e33621169e44 | 1221 | * identifies "bar" edges and measures width between them. |
hudakz | 0:e33621169e44 | 1222 | * optionally passes to bar width decoder |
hudakz | 0:e33621169e44 | 1223 | */ |
hudakz | 0:e33621169e44 | 1224 | /*@{*/ |
hudakz | 0:e33621169e44 | 1225 | |
hudakz | 0:e33621169e44 | 1226 | struct zbar_scanner_s; |
hudakz | 0:e33621169e44 | 1227 | /** opaque scanner object. */ |
hudakz | 0:e33621169e44 | 1228 | typedef struct zbar_scanner_s zbar_scanner_t; |
hudakz | 0:e33621169e44 | 1229 | |
hudakz | 0:e33621169e44 | 1230 | /** constructor. |
hudakz | 0:e33621169e44 | 1231 | * if decoder is non-NULL it will be attached to scanner |
hudakz | 0:e33621169e44 | 1232 | * and called automatically at each new edge |
hudakz | 0:e33621169e44 | 1233 | * current color is initialized to ::ZBAR_SPACE |
hudakz | 0:e33621169e44 | 1234 | * (so an initial BAR->SPACE transition may be discarded) |
hudakz | 0:e33621169e44 | 1235 | */ |
hudakz | 0:e33621169e44 | 1236 | extern zbar_scanner_t *zbar_scanner_create(zbar_decoder_t *decoder); |
hudakz | 0:e33621169e44 | 1237 | |
hudakz | 0:e33621169e44 | 1238 | /** destructor. */ |
hudakz | 0:e33621169e44 | 1239 | extern void zbar_scanner_destroy(zbar_scanner_t *scanner); |
hudakz | 0:e33621169e44 | 1240 | |
hudakz | 0:e33621169e44 | 1241 | /** clear all scanner state. |
hudakz | 0:e33621169e44 | 1242 | * also resets an associated decoder |
hudakz | 0:e33621169e44 | 1243 | */ |
hudakz | 0:e33621169e44 | 1244 | extern zbar_symbol_type_t zbar_scanner_reset(zbar_scanner_t *scanner); |
hudakz | 0:e33621169e44 | 1245 | |
hudakz | 0:e33621169e44 | 1246 | /** mark start of a new scan pass. resets color to ::ZBAR_SPACE. |
hudakz | 0:e33621169e44 | 1247 | * also updates an associated decoder. |
hudakz | 0:e33621169e44 | 1248 | * @returns any decode results flushed from the pipeline |
hudakz | 0:e33621169e44 | 1249 | * @note when not using callback handlers, the return value should |
hudakz | 0:e33621169e44 | 1250 | * be checked the same as zbar_scan_y() |
hudakz | 0:e33621169e44 | 1251 | * @note call zbar_scanner_flush() at least twice before calling this |
hudakz | 0:e33621169e44 | 1252 | * method to ensure no decode results are lost |
hudakz | 0:e33621169e44 | 1253 | */ |
hudakz | 0:e33621169e44 | 1254 | extern zbar_symbol_type_t zbar_scanner_new_scan(zbar_scanner_t *scanner); |
hudakz | 0:e33621169e44 | 1255 | |
hudakz | 0:e33621169e44 | 1256 | /** flush scanner processing pipeline. |
hudakz | 0:e33621169e44 | 1257 | * forces current scanner position to be a scan boundary. |
hudakz | 0:e33621169e44 | 1258 | * call multiple times (max 3) to completely flush decoder. |
hudakz | 0:e33621169e44 | 1259 | * @returns any decode/scan results flushed from the pipeline |
hudakz | 0:e33621169e44 | 1260 | * @note when not using callback handlers, the return value should |
hudakz | 0:e33621169e44 | 1261 | * be checked the same as zbar_scan_y() |
hudakz | 0:e33621169e44 | 1262 | * @since 0.9 |
hudakz | 0:e33621169e44 | 1263 | */ |
hudakz | 0:e33621169e44 | 1264 | extern zbar_symbol_type_t zbar_scanner_flush(zbar_scanner_t *scanner); |
hudakz | 0:e33621169e44 | 1265 | |
hudakz | 0:e33621169e44 | 1266 | /** process next sample intensity value. |
hudakz | 0:e33621169e44 | 1267 | * intensity (y) is in arbitrary relative units. |
hudakz | 0:e33621169e44 | 1268 | * @returns result of zbar_decode_width() if a decoder is attached, |
hudakz | 0:e33621169e44 | 1269 | * otherwise @returns (::ZBAR_PARTIAL) when new edge is detected |
hudakz | 0:e33621169e44 | 1270 | * or 0 (::ZBAR_NONE) if no new edge is detected |
hudakz | 0:e33621169e44 | 1271 | */ |
hudakz | 0:e33621169e44 | 1272 | extern zbar_symbol_type_t zbar_scan_y(zbar_scanner_t *scanner, |
hudakz | 0:e33621169e44 | 1273 | int y); |
hudakz | 0:e33621169e44 | 1274 | |
hudakz | 0:e33621169e44 | 1275 | /** process next sample from RGB (or BGR) triple. */ |
hudakz | 0:e33621169e44 | 1276 | static inline zbar_symbol_type_t zbar_scan_rgb24 (zbar_scanner_t *scanner, |
hudakz | 0:e33621169e44 | 1277 | unsigned char *rgb) |
hudakz | 0:e33621169e44 | 1278 | { |
hudakz | 0:e33621169e44 | 1279 | return(zbar_scan_y(scanner, rgb[0] + rgb[1] + rgb[2])); |
hudakz | 0:e33621169e44 | 1280 | } |
hudakz | 0:e33621169e44 | 1281 | |
hudakz | 0:e33621169e44 | 1282 | /** retrieve last scanned width. */ |
hudakz | 0:e33621169e44 | 1283 | extern unsigned zbar_scanner_get_width(const zbar_scanner_t *scanner); |
hudakz | 0:e33621169e44 | 1284 | |
hudakz | 0:e33621169e44 | 1285 | /** retrieve sample position of last edge. |
hudakz | 0:e33621169e44 | 1286 | * @since 0.10 |
hudakz | 0:e33621169e44 | 1287 | */ |
hudakz | 0:e33621169e44 | 1288 | extern unsigned zbar_scanner_get_edge(const zbar_scanner_t *scn, |
hudakz | 0:e33621169e44 | 1289 | unsigned offset, |
hudakz | 0:e33621169e44 | 1290 | int prec); |
hudakz | 0:e33621169e44 | 1291 | |
hudakz | 0:e33621169e44 | 1292 | /** retrieve last scanned color. */ |
hudakz | 0:e33621169e44 | 1293 | extern zbar_color_t zbar_scanner_get_color(const zbar_scanner_t *scanner); |
hudakz | 0:e33621169e44 | 1294 | |
hudakz | 0:e33621169e44 | 1295 | /*@}*/ |
hudakz | 0:e33621169e44 | 1296 | |
hudakz | 0:e33621169e44 | 1297 | #ifdef __cplusplus |
hudakz | 0:e33621169e44 | 1298 | } |
hudakz | 0:e33621169e44 | 1299 | } |
hudakz | 0:e33621169e44 | 1300 | |
hudakz | 0:e33621169e44 | 1301 | //# include "zbar/Exception.h" |
hudakz | 0:e33621169e44 | 1302 | # include "zbar/Decoder.h" |
hudakz | 0:e33621169e44 | 1303 | # include "zbar/Scanner.h" |
hudakz | 0:e33621169e44 | 1304 | # include "zbar/Symbol.h" |
hudakz | 0:e33621169e44 | 1305 | //# include "zbar/Image.h" |
hudakz | 0:e33621169e44 | 1306 | //# include "zbar/ImageScanner.h" |
hudakz | 0:e33621169e44 | 1307 | //# include "zbar/Video.h" |
hudakz | 0:e33621169e44 | 1308 | //# include "zbar/Window.h" |
hudakz | 0:e33621169e44 | 1309 | //# include "zbar/Processor.h" |
hudakz | 0:e33621169e44 | 1310 | #endif |
hudakz | 0:e33621169e44 | 1311 | |
hudakz | 0:e33621169e44 | 1312 | #endif |