Skip to content

Commit

Permalink
add support for EAN/UPC 2 and 5 digit add-on symbols (draft)
Browse files Browse the repository at this point in the history
    - deprecate original, unfinished add-on APIs
    - add self-checking to test_decode
  • Loading branch information
spadix0 committed Dec 12, 2010
1 parent ea1e5b6 commit 954f611
Show file tree
Hide file tree
Showing 19 changed files with 453 additions and 174 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
@@ -1,4 +1,7 @@
current:
* add support for EAN/UPC 2 and 5 digit add-on symbols
- deprecate original, unfinished add-on APIs
- add self-checking to test_decode
* add coarse symbol orientation information (patch #2913094)
- thanks to Anssi for a patch!
- add decode direction feedback to decoder
Expand Down
1 change: 0 additions & 1 deletion TODO
Expand Up @@ -25,7 +25,6 @@ symbologies:
* Code 39, i25 optional features (check digit and ASCII escapes)
* handle Code 128 function characters (FNC1-4)
* Code 128 trailing quiet zone checks
* finish addon decoding

decoder:
* start/stop/abort and location detail APIs (PDF417, OMR)
Expand Down
1 change: 0 additions & 1 deletion gtk/zbargtk.c
Expand Up @@ -231,7 +231,6 @@ static inline int zbar_gtk_process_image (ZBarGtk *self,

/* FIXME skip this when unconnected? */
gchar *text = g_strconcat(zbar_get_symbol_name(type),
zbar_get_addon_name(type),
":",
data,
NULL);
Expand Down
31 changes: 26 additions & 5 deletions include/zbar.h
Expand Up @@ -86,21 +86,41 @@ typedef enum zbar_color_e {
typedef enum zbar_symbol_type_e {
ZBAR_NONE = 0, /**< no symbol decoded */
ZBAR_PARTIAL = 1, /**< intermediate status */
ZBAR_EAN2 = 2, /**< GS1 2-digit add-on */
ZBAR_EAN5 = 5, /**< GS1 5-digit add-on */
ZBAR_EAN8 = 8, /**< EAN-8 */
ZBAR_UPCE = 9, /**< UPC-E */
ZBAR_ISBN10 = 10, /**< ISBN-10 (from EAN-13). @since 0.4 */
ZBAR_UPCA = 12, /**< UPC-A */
ZBAR_EAN13 = 13, /**< EAN-13 */
ZBAR_ISBN13 = 14, /**< ISBN-13 (from EAN-13). @since 0.4 */
ZBAR_EANUPC = 15, /**< EAN/UPC composite */
ZBAR_I25 = 25, /**< Interleaved 2 of 5. @since 0.4 */
ZBAR_CODE39 = 39, /**< Code 39. @since 0.4 */
ZBAR_PDF417 = 57, /**< PDF417. @since 0.6 */
ZBAR_QRCODE = 64, /**< QR Code. @since 0.10 */
ZBAR_CODE128 = 128, /**< Code 128 */
ZBAR_SYMBOL = 0x00ff, /**< mask for base symbol type */
ZBAR_ADDON2 = 0x0200, /**< 2-digit add-on flag */
ZBAR_ADDON5 = 0x0500, /**< 5-digit add-on flag */
ZBAR_ADDON = 0x0700, /**< add-on flag mask */

/** mask for base symbol type.
* @deprecated in 0.11, remove this from existing code
*/
ZBAR_SYMBOL = 0x00ff,
/** 2-digit add-on flag.
* @deprecated in 0.11, a ::ZBAR_EAN2 component is used for
* 2-digit GS1 add-ons
*/
ZBAR_ADDON2 = 0x0200,
/** 5-digit add-on flag.
* @deprecated in 0.11, a ::ZBAR_EAN5 component is used for
* 5-digit GS1 add-ons
*/
ZBAR_ADDON5 = 0x0500,
/** add-on flag mask.
* @deprecated in 0.11, GS1 add-ons are represented using composite
* symbols of type ::ZBAR_EANUPC; add-on components use ::ZBAR_EAN2
* or ::ZBAR_EAN5
*/
ZBAR_ADDON = 0x0700,
} zbar_symbol_type_t;

/** decoded symbol coarse orientation.
Expand Down Expand Up @@ -179,6 +199,7 @@ extern const char *zbar_get_symbol_name(zbar_symbol_type_t sym);
* @param sym symbol type encoding
* @returns static string name for any addon, or the empty string
* if no addons were decoded
* @deprecated in 0.11
*/
extern const char *zbar_get_addon_name(zbar_symbol_type_t sym);

Expand Down Expand Up @@ -329,7 +350,7 @@ extern int zbar_symbol_get_loc_y(const zbar_symbol_t *symbol,

/** retrieve general orientation of decoded symbol.
* @returns a coarse, axis-aligned indication of symbol orientation or
* ZBAR_ORIENT_UNKNOWN if unknown
* ::ZBAR_ORIENT_UNKNOWN if unknown
* @since 0.11
*/
extern zbar_orientation_t
Expand Down
1 change: 1 addition & 0 deletions include/zbar/Decoder.h
Expand Up @@ -115,6 +115,7 @@ class Decoder {

/// retrieve string name for last decode addon.
/// see zbar_get_addon_name()
/// @deprecated in 0.11
const char *get_addon_name () const
{
return(zbar_get_addon_name(zbar_decoder_get_type(_decoder)));
Expand Down
5 changes: 2 additions & 3 deletions include/zbar/Symbol.h
Expand Up @@ -250,6 +250,7 @@ class Symbol {
}

/// retrieve the string name for any addon.
/// @deprecated in 0.11
const std::string get_addon_name () const
{
return(zbar_get_addon_name(_type));
Expand Down Expand Up @@ -447,9 +448,7 @@ inline const SymbolIterator SymbolSet::symbol_end () const {
static inline std::ostream& operator<< (std::ostream& out,
const Symbol& sym)
{
out << sym.get_type_name()
<< sym.get_addon_name()
<< ":" << sym.get_data();
out << sym.get_type_name() << ":" << sym.get_data();
return(out);
}

Expand Down
3 changes: 1 addition & 2 deletions qt/QZBarThread.cpp
Expand Up @@ -26,7 +26,7 @@

using namespace zbar;

static const QString textFormat("%1%2:%3");
static const QString textFormat("%1:%2");

QZBarThread::QZBarThread ()
: _videoOpened(false),
Expand All @@ -52,7 +52,6 @@ void QZBarThread::image_callback (Image &image)

emit decodedText(textFormat.arg(
QString::fromStdString(sym->get_type_name()),
QString::fromStdString(sym->get_addon_name()),
data));
}
}
Expand Down

0 comments on commit 954f611

Please sign in to comment.