![]() |
Leptonica
1.82.0
Image processing and image analysis suite
|
#include <string.h>
#include "allheaders.h"
#include "readbarcode.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_CODES 0 |
Functions | |
static l_int32 | barcodeFindFormat (char *barstr) |
static l_int32 | barcodeVerifyFormat (char *barstr, l_int32 format, l_int32 *pvalid, l_int32 *preverse) |
static char * | barcodeDecode2of5 (char *barstr, l_int32 debugflag) |
static char * | barcodeDecodeI2of5 (char *barstr, l_int32 debugflag) |
static char * | barcodeDecode93 (char *barstr, l_int32 debugflag) |
static char * | barcodeDecode39 (char *barstr, l_int32 debugflag) |
static char * | barcodeDecodeCodabar (char *barstr, l_int32 debugflag) |
static char * | barcodeDecodeUpca (char *barstr, l_int32 debugflag) |
static char * | barcodeDecodeEan13 (char *barstr, l_int32 first, l_int32 debugflag) |
char * | barcodeDispatchDecoder (char *barstr, l_int32 format, l_int32 debugflag) |
l_int32 | barcodeFormatIsSupported (l_int32 format) |
Dispatcher char *barcodeDispatchDecoder() Format Determination static l_int32 barcodeFindFormat() l_int32 barcodeFormatIsSupported() static l_int32 barcodeVerifyFormat() Decode 2 of 5 static char *barcodeDecode2of5() Decode Interleaved 2 of 5 static char *barcodeDecodeI2of5() Decode Code 93 static char *barcodeDecode93() Decode Code 39 static char *barcodeDecode39() Decode Codabar static char *barcodeDecodeCodabar() Decode UPC-A static char *barcodeDecodeUpca() Decode EAN 13 static char *barcodeDecodeEan13()
Definition in file bardecode.c.
|
static |
[in] | barstr | of widths, in set {1, 2} |
[in] | debugflag |
Notes: (1) Ref: http://en.wikipedia.org/wiki/Two-out-of-five_code (Note: the codes given here are wrong!) http://morovia.com/education/symbology/code25.asp (2) This is a very low density encoding for the 10 digits. Each digit is encoded with 5 black bars, of which 2 are wide and 3 are narrow. No information is carried in the spaces between the bars, which are all equal in width, represented by a "1" in our encoding. (3) The mapping from the sequence of five bar widths to the digit is identical to the mapping used by the interleaved 2 of 5 code. The start code is 21211, representing two wide bars and a narrow bar, and the interleaved "1" spaces are explicit. The stop code is 21112. For all codes (including start and stop), the trailing space "1" is implicit -- there is no reason to represent it in the Code2of5[] array.
Definition at line 378 of file bardecode.c.
References barcodeVerifyFormat(), lept_stderr(), stringNew(), and stringReverse().
Referenced by barcodeDispatchDecoder().
|
static |
[in] | barstr | of widths, in set {1, 2} |
[in] | debugflag |
Notes: (1) Ref: http://en.wikipedia.org/wiki/Code39 http://morovia.com/education/symbology/code39.asp (2) Each symbol has 5 black and 4 white bars. The start and stop codes are 121121211 (the asterisk) (3) This decoder was contributed by Roger Hyde.
Definition at line 672 of file bardecode.c.
References barcodeVerifyFormat(), lept_stderr(), stringNew(), and stringReverse().
Referenced by barcodeDispatchDecoder().
|
static |
[in] | barstr | of widths, in set {1, 2, 3, 4} |
[in] | debugflag |
Notes: (1) Ref: http://en.wikipedia.org/wiki/Code93 http://morovia.com/education/symbology/code93.asp (2) Each symbol has 3 black and 3 white bars. The start and stop codes are 111141; the stop code then is terminated with a final (1) bar. (3) The last two codes are check codes. We are checking them for correctness, and issuing a warning on failure. Should probably not return any data on failure.
Definition at line 555 of file bardecode.c.
References barcodeVerifyFormat(), lept_stderr(), stringNew(), and stringReverse().
Referenced by barcodeDispatchDecoder().
|
static |
[in] | barstr | of widths, in set {1, 2} |
[in] | debugflag |
Notes: (1) Ref: http://en.wikipedia.org/wiki/Codabar http://morovia.com/education/symbology/codabar.asp (2) Each symbol has 4 black and 3 white bars. They represent the 10 digits, and optionally 6 other characters. The start and stop codes can be any of four (typically denoted A,B,C,D).
Definition at line 755 of file bardecode.c.
References barcodeVerifyFormat(), lept_stderr(), stringNew(), and stringReverse().
Referenced by barcodeDispatchDecoder().
|
static |
[in] | barstr | of widths, in set {1, 2, 3, 4} |
[in] | first | first digit: 0 - 9 |
[in] | debugflag |
Notes: (1) Ref: http://en.wikipedia.org/wiki/UniversalProductCode http://morovia.com/education/symbology/ean-13.asp (2) The encoding is essentially the same as UPC-A, except there are 13 digits in total, of which 12 are encoded by bars (as with UPC-A) and the 13th is a leading digit that determines the encoding of the next 6 digits, selecting each digit from one of two tables. encoded in the bars (as with UPC-A). If the first digit is 0, the encoding is identical to UPC-A. (3) As with UPC-A, the last digit is a check digit. (4) For now, we assume the first digit is input to this function. Eventually, we will read it by pattern matching. TODO: fix this for multiple tables, depending on the value of first
Definition at line 960 of file bardecode.c.
References barcodeVerifyFormat(), lept_stderr(), stringNew(), and stringReverse().
Referenced by barcodeDispatchDecoder().
|
static |
[in] | barstr | of widths, in set {1, 2} |
[in] | debugflag |
Notes: (1) Ref: http://en.wikipedia.org/wiki/Interleaved_2_of_5 (2) This always encodes an even number of digits. The start code is 1111; the stop code is 211.
Definition at line 458 of file bardecode.c.
References barcodeVerifyFormat(), lept_stderr(), stringNew(), and stringReverse().
Referenced by barcodeDispatchDecoder().
|
static |
[in] | barstr | of widths, in set {1, 2, 3, 4} |
[in] | debugflag |
Notes: (1) Ref: http://en.wikipedia.org/wiki/UniversalProductCode http://morovia.com/education/symbology/upc-a.asp (2) Each symbol has 2 black and 2 white bars, and encodes a digit. The start and stop codes are 111 and 111. There are a total of 30 black bars, encoding 12 digits in two sets of 6, with 2 black bars separating the sets. (3) The last digit is a check digit. We check for correctness, and issue a warning on failure. Should probably not return any data on failure.
Definition at line 843 of file bardecode.c.
References barcodeVerifyFormat(), lept_stderr(), stringNew(), and stringReverse().
Referenced by barcodeDispatchDecoder().
char* barcodeDispatchDecoder | ( | char * | barstr, |
l_int32 | format, | ||
l_int32 | debugflag | ||
) |
[in] | barstr | string of integers in set {1,2,3,4} of bar widths |
[in] | format | L_BF_ANY, L_BF_CODEI2OF5, L_BF_CODE93, ... |
[in] | debugflag | use 1 to generate debug output |
Definition at line 97 of file bardecode.c.
References barcodeDecode2of5(), barcodeDecode39(), barcodeDecode93(), barcodeDecodeCodabar(), barcodeDecodeEan13(), barcodeDecodeI2of5(), barcodeDecodeUpca(), and barcodeFindFormat().
|
static |
[in] | barstr | of barcode widths, in set {1,2,3,4} |
Definition at line 144 of file bardecode.c.
References barcodeVerifyFormat().
Referenced by barcodeDispatchDecoder().
l_int32 barcodeFormatIsSupported | ( | l_int32 | format | ) |
[in] | format |
Definition at line 174 of file bardecode.c.
Referenced by pixProcessBarcodes(), and pixReadBarcodes().
|
static |
[in] | barstr | of barcode widths, in set {1,2,3,4} |
[in] | format | L_BF_CODEI2OF5, L_BF_CODE93, ... |
[out] | pvalid | 0 if not valid, 1 and 2 if valid |
[out] | preverse | [optional] 1 if reversed; 0 otherwise |
Notes: (1) If valid == 1, the barcode is of the given format in the forward order; if valid == 2, it is backwards. (2) If the barcode needs to be reversed to read it, and &reverse is provided, a 1 is put into reverse. (3) Require at least 12 data bits, in addition to format identifiers. (TODO) If the barcode has a fixed length, this should be used explicitly, as is done for L_BF_UPCA and L_BF_EAN13. (4) (TODO) Add to this as more formats are supported.
Definition at line 208 of file bardecode.c.
References stringReverse().
Referenced by barcodeDecode2of5(), barcodeDecode39(), barcodeDecode93(), barcodeDecodeCodabar(), barcodeDecodeEan13(), barcodeDecodeI2of5(), barcodeDecodeUpca(), and barcodeFindFormat().