ZBar bar code reader . http://zbar.sourceforge.net/ ZBar is licensed under the GNU LGPL 2.1 to enable development of both open source and commercial projects.

Dependents:   GR-PEACH_Camera_in_barcode levkov_ov7670

LICENSE

The ZBar Bar Code Reader is Copyright (C) 2007-2009 Jeff Brown <spadix@users.sourceforge.net> The QR Code reader is Copyright (C) 1999-2009 Timothy B. Terriberry <tterribe@xiph.org>

You can redistribute this library and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

ISAAC is based on the public domain implementation by Robert J. Jenkins Jr., and is itself public domain.

Portions of the bit stream reader are copyright (C) The Xiph.Org Foundation 1994-2008, and are licensed under a BSD-style license.

The Reed-Solomon decoder is derived from an implementation (C) 1991-1995 Henry Minsky (hqm@ua.com, hqm@ai.mit.edu), and is licensed under the LGPL with permission.

Committer:
RyoheiHagimoto
Date:
Tue Apr 19 02:00:37 2016 +0000
Revision:
0:56c5742b9e2b
First revicion

Who changed what in which revision?

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