motion-ocr 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +10 -0
- data/LICENSE +28 -0
- data/README.md +22 -0
- data/Rakefile +17 -0
- data/app/app_delegate.rb +2 -0
- data/lib/motion-ocr.rb +26 -0
- data/lib/motion-ocr/version.rb +3 -0
- data/motion-ocr.gemspec +20 -0
- data/resources/tessdata/configs/nodict +3 -0
- data/resources/tessdata/eng.traineddata +0 -0
- data/spec/motion_ocr_spec.rb +23 -0
- data/spec/support/phototest.gif +0 -0
- data/vendor/MotionOCR/MotionOCR.bridgesupport +14722 -0
- data/vendor/MotionOCR/MotionOCR.xcodeproj/project.pbxproj +390 -0
- data/vendor/MotionOCR/MotionOCR.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/vendor/MotionOCR/MotionOCR.xcodeproj/project.xcworkspace/xcuserdata/fer.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- data/vendor/MotionOCR/MotionOCR.xcodeproj/xcuserdata/fer.xcuserdatad/xcschemes/MotionOCR.xcscheme +59 -0
- data/vendor/MotionOCR/MotionOCR.xcodeproj/xcuserdata/fer.xcuserdatad/xcschemes/xcschememanagement.plist +22 -0
- data/vendor/MotionOCR/MotionOCR/MotionOCR-Prefix.pch +7 -0
- data/vendor/MotionOCR/MotionOCR/MotionOCR.h +22 -0
- data/vendor/MotionOCR/MotionOCR/MotionOCR.mm +89 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/allheaders.h +32 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/alltypes.h +49 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/array.h +125 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/arrayaccess.h +194 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/bbuffer.h +46 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/bmf.h +51 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/bmp.h +74 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/ccbord.h +103 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/dewarp.h +57 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/endianness.h +11 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/environ.h +281 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/freetype.h +23 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/gplot.h +77 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/heap.h +73 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/imageio.h +153 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/jbclass.h +122 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/leptprotos.h +2058 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/leptwin.h +34 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/list.h +76 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/morph.h +218 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/pix.h +945 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/ptra.h +80 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/queue.h +63 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/readbarcode.h +220 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/regutils.h +122 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/stack.h +55 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/sudoku.h +62 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/watershed.h +52 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/apitypes.h +31 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/baseapi.h +664 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/errcode.h +104 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/genericvector.h +763 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/helpers.h +139 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/host.h +180 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/ndminx.h +31 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/ocrclass.h +335 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/platform.h +48 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/publictypes.h +202 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/tesscallback.h +1238 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/thresholder.h +170 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/unichar.h +85 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/lib/liblept.a +0 -0
- data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/lib/libtesseract_all.a +0 -0
- metadata +113 -0
@@ -0,0 +1,80 @@
|
|
1
|
+
/*====================================================================*
|
2
|
+
- Copyright (C) 2001 Leptonica. All rights reserved.
|
3
|
+
- This software is distributed in the hope that it will be
|
4
|
+
- useful, but with NO WARRANTY OF ANY KIND.
|
5
|
+
- No author or distributor accepts responsibility to anyone for the
|
6
|
+
- consequences of using this software, or for whether it serves any
|
7
|
+
- particular purpose or works at all, unless he or she says so in
|
8
|
+
- writing. Everyone is granted permission to copy, modify and
|
9
|
+
- redistribute this source code, for commercial or non-commercial
|
10
|
+
- purposes, with the following restrictions: (1) the origin of this
|
11
|
+
- source code must not be misrepresented; (2) modified versions must
|
12
|
+
- be plainly marked as such; and (3) this notice may not be removed
|
13
|
+
- or altered from any source or modified source distribution.
|
14
|
+
*====================================================================*/
|
15
|
+
|
16
|
+
#ifndef LEPTONICA_PTRA_H
|
17
|
+
#define LEPTONICA_PTRA_H
|
18
|
+
|
19
|
+
/*
|
20
|
+
* Contains the following structs:
|
21
|
+
* struct L_Ptra
|
22
|
+
* struct L_Ptraa
|
23
|
+
*
|
24
|
+
* Contains definitions for:
|
25
|
+
* L_Ptra compaction flags for removal
|
26
|
+
* L_Ptra shifting flags for insert
|
27
|
+
* L_Ptraa accessor flags
|
28
|
+
*/
|
29
|
+
|
30
|
+
|
31
|
+
/*------------------------------------------------------------------------*
|
32
|
+
* Generic Ptr Array Structs *
|
33
|
+
*------------------------------------------------------------------------*/
|
34
|
+
|
35
|
+
/* Generic pointer array */
|
36
|
+
struct L_Ptra
|
37
|
+
{
|
38
|
+
l_int32 nalloc; /* size of allocated ptr array */
|
39
|
+
l_int32 imax; /* greatest valid index */
|
40
|
+
l_int32 nactual; /* actual number of stored elements */
|
41
|
+
void **array; /* ptr array */
|
42
|
+
};
|
43
|
+
typedef struct L_Ptra L_PTRA;
|
44
|
+
|
45
|
+
|
46
|
+
/* Array of generic pointer arrays */
|
47
|
+
struct L_Ptraa
|
48
|
+
{
|
49
|
+
l_int32 nalloc; /* size of allocated ptr array */
|
50
|
+
struct L_Ptra **ptra; /* array of ptra */
|
51
|
+
};
|
52
|
+
typedef struct L_Ptraa L_PTRAA;
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
/*------------------------------------------------------------------------*
|
57
|
+
* Array flags *
|
58
|
+
*------------------------------------------------------------------------*/
|
59
|
+
|
60
|
+
/* Flags for removal from L_Ptra */
|
61
|
+
enum {
|
62
|
+
L_NO_COMPACTION = 1, /* null the pointer only */
|
63
|
+
L_COMPACTION = 2 /* compact the array */
|
64
|
+
};
|
65
|
+
|
66
|
+
/* Flags for insertion into L_Ptra */
|
67
|
+
enum {
|
68
|
+
L_AUTO_DOWNSHIFT = 0, /* choose based on number of holes */
|
69
|
+
L_MIN_DOWNSHIFT = 1, /* downshifts min # of ptrs below insert */
|
70
|
+
L_FULL_DOWNSHIFT = 2 /* downshifts all ptrs below insert */
|
71
|
+
};
|
72
|
+
|
73
|
+
/* Accessor flags for L_Ptraa */
|
74
|
+
enum {
|
75
|
+
L_HANDLE_ONLY = 0, /* ptr to L_Ptra; caller can inspect only */
|
76
|
+
L_REMOVE = 1 /* caller owns; destroy or save in L_Ptraa */
|
77
|
+
};
|
78
|
+
|
79
|
+
|
80
|
+
#endif /* LEPTONICA_PTRA_H */
|
@@ -0,0 +1,63 @@
|
|
1
|
+
/*====================================================================*
|
2
|
+
- Copyright (C) 2001 Leptonica. All rights reserved.
|
3
|
+
- This software is distributed in the hope that it will be
|
4
|
+
- useful, but with NO WARRANTY OF ANY KIND.
|
5
|
+
- No author or distributor accepts responsibility to anyone for the
|
6
|
+
- consequences of using this software, or for whether it serves any
|
7
|
+
- particular purpose or works at all, unless he or she says so in
|
8
|
+
- writing. Everyone is granted permission to copy, modify and
|
9
|
+
- redistribute this source code, for commercial or non-commercial
|
10
|
+
- purposes, with the following restrictions: (1) the origin of this
|
11
|
+
- source code must not be misrepresented; (2) modified versions must
|
12
|
+
- be plainly marked as such; and (3) this notice may not be removed
|
13
|
+
- or altered from any source or modified source distribution.
|
14
|
+
*====================================================================*/
|
15
|
+
|
16
|
+
#ifndef LEPTONICA_QUEUE_H
|
17
|
+
#define LEPTONICA_QUEUE_H
|
18
|
+
|
19
|
+
/*
|
20
|
+
* queue.h
|
21
|
+
*
|
22
|
+
* Expandable pointer queue for arbitrary void* data.
|
23
|
+
*
|
24
|
+
* The L_Queue is a fifo that implements a queue of void* pointers.
|
25
|
+
* It can be used to hold a queue of any type of struct.
|
26
|
+
*
|
27
|
+
* Internally, it maintains two counters:
|
28
|
+
* nhead: location of head (in ptrs) from the beginning
|
29
|
+
* of the array.
|
30
|
+
* nelem: number of ptr elements stored in the queue.
|
31
|
+
*
|
32
|
+
* The element at the head of the queue, which is the next to
|
33
|
+
* be removed, is array[nhead]. The location at the tail of the
|
34
|
+
* queue to which the next element will be added is
|
35
|
+
* array[nhead + nelem].
|
36
|
+
*
|
37
|
+
* As items are added to the queue, nelem increases.
|
38
|
+
* As items are removed, nhead increases and nelem decreases.
|
39
|
+
* Any time the tail reaches the end of the allocated array,
|
40
|
+
* all the pointers are shifted to the left, so that the head
|
41
|
+
* is at the beginning of the array.
|
42
|
+
* If the array becomes more than 3/4 full, it doubles in size.
|
43
|
+
*
|
44
|
+
* The auxiliary stack can be used in a wrapper for re-using
|
45
|
+
* items popped from the queue. It is not made by default.
|
46
|
+
*
|
47
|
+
* For further implementation details, see queue.c.
|
48
|
+
*/
|
49
|
+
|
50
|
+
struct L_Queue
|
51
|
+
{
|
52
|
+
l_int32 nalloc; /* size of allocated ptr array */
|
53
|
+
l_int32 nhead; /* location of head (in ptrs) from the */
|
54
|
+
/* beginning of the array */
|
55
|
+
l_int32 nelem; /* number of elements stored in the queue */
|
56
|
+
void **array; /* ptr array */
|
57
|
+
struct L_Stack *stack; /* auxiliary stack */
|
58
|
+
|
59
|
+
};
|
60
|
+
typedef struct L_Queue L_QUEUE;
|
61
|
+
|
62
|
+
|
63
|
+
#endif /* LEPTONICA_QUEUE_H */
|
data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/readbarcode.h
ADDED
@@ -0,0 +1,220 @@
|
|
1
|
+
/*====================================================================*
|
2
|
+
- Copyright (C) 2001 Leptonica. All rights reserved.
|
3
|
+
- This software is distributed in the hope that it will be
|
4
|
+
- useful, but with NO WARRANTY OF ANY KIND.
|
5
|
+
- No author or distributor accepts responsibility to anyone for the
|
6
|
+
- consequences of using this software, or for whether it serves any
|
7
|
+
- particular purpose or works at all, unless he or she says so in
|
8
|
+
- writing. Everyone is granted permission to copy, modify and
|
9
|
+
- redistribute this source code, for commercial or non-commercial
|
10
|
+
- purposes, with the following restrictions: (1) the origin of this
|
11
|
+
- source code must not be misrepresented; (2) modified versions must
|
12
|
+
- be plainly marked as such; and (3) this notice may not be removed
|
13
|
+
- or altered from any source or modified source distribution.
|
14
|
+
*====================================================================*/
|
15
|
+
|
16
|
+
#ifndef LEPTONICA_READBARCODE_H
|
17
|
+
#define LEPTONICA_READBARCODE_H
|
18
|
+
|
19
|
+
/* ----------------------------------------------------------------- *
|
20
|
+
* Flags for method of extracting barcode widths *
|
21
|
+
* ----------------------------------------------------------------- */
|
22
|
+
enum {
|
23
|
+
L_USE_WIDTHS = 1, /* use histogram of barcode widths */
|
24
|
+
L_USE_WINDOWS = 2 /* find best window for decoding transitions */
|
25
|
+
};
|
26
|
+
|
27
|
+
/* ----------------------------------------------------------------- *
|
28
|
+
* Flags for barcode formats *
|
29
|
+
* These are used both to identify a barcode format and to identify *
|
30
|
+
* the decoding method to use on a barcode. *
|
31
|
+
* ----------------------------------------------------------------- */
|
32
|
+
enum {
|
33
|
+
L_BF_UNKNOWN = 0, /* unknown format */
|
34
|
+
L_BF_ANY = 1, /* try decoding with all known formats */
|
35
|
+
L_BF_CODE128 = 2, /* decode with Code128 format */
|
36
|
+
L_BF_EAN8 = 3, /* decode with EAN8 format */
|
37
|
+
L_BF_EAN13 = 4, /* decode with EAN13 format */
|
38
|
+
L_BF_CODE2OF5 = 5, /* decode with Code 2 of 5 format */
|
39
|
+
L_BF_CODEI2OF5 = 6, /* decode with Interleaved 2 of 5 format */
|
40
|
+
L_BF_CODE39 = 7, /* decode with Code39 format */
|
41
|
+
L_BF_CODE93 = 8, /* decode with Code93 format */
|
42
|
+
L_BF_CODABAR = 9, /* decode with Code93 format */
|
43
|
+
L_BF_UPCA = 10 /* decode with UPC A format */
|
44
|
+
};
|
45
|
+
|
46
|
+
/* ----------------------------------------------------------------- *
|
47
|
+
* Currently supported formats *
|
48
|
+
* Update these arrays as new formats are added. *
|
49
|
+
* ----------------------------------------------------------------- */
|
50
|
+
static const l_int32 SupportedBarcodeFormat[] = {
|
51
|
+
L_BF_CODE2OF5,
|
52
|
+
L_BF_CODEI2OF5,
|
53
|
+
L_BF_CODE93,
|
54
|
+
L_BF_CODE39,
|
55
|
+
L_BF_CODABAR,
|
56
|
+
L_BF_UPCA,
|
57
|
+
L_BF_EAN13
|
58
|
+
};
|
59
|
+
static const char *SupportedBarcodeFormatName[] = {
|
60
|
+
"Code2of5",
|
61
|
+
"CodeI2of5",
|
62
|
+
"Code93",
|
63
|
+
"Code39",
|
64
|
+
"Codabar",
|
65
|
+
"Upca",
|
66
|
+
"Ean13"
|
67
|
+
};
|
68
|
+
static const l_int32 NumSupportedBarcodeFormats = 7;
|
69
|
+
|
70
|
+
|
71
|
+
/* ----------------------------------------------------------------- *
|
72
|
+
* Code 2 of 5 symbology *
|
73
|
+
* ----------------------------------------------------------------- */
|
74
|
+
static const char *Code2of5[] = {
|
75
|
+
"111121211", "211111112", "112111112", "212111111", /* 0 - 3 */
|
76
|
+
"111121112", "211121111", "112121111", "111111212", /* 4 - 7 */
|
77
|
+
"211111211", "112111211", /* 8 - 9 */
|
78
|
+
"21211", "21112" /* Start, Stop */
|
79
|
+
};
|
80
|
+
|
81
|
+
static const l_int32 C25_START = 10;
|
82
|
+
static const l_int32 C25_STOP = 11;
|
83
|
+
|
84
|
+
|
85
|
+
/* ----------------------------------------------------------------- *
|
86
|
+
* Code Interleaved 2 of 5 symbology *
|
87
|
+
* ----------------------------------------------------------------- */
|
88
|
+
static const char *CodeI2of5[] = {
|
89
|
+
"11221", "21112", "12112", "22111", "11212", /* 0 - 4 */
|
90
|
+
"21211", "12211", "11122", "21121", "12121", /* 5 - 9 */
|
91
|
+
"1111", "211" /* start, stop */
|
92
|
+
};
|
93
|
+
|
94
|
+
static const l_int32 CI25_START = 10;
|
95
|
+
static const l_int32 CI25_STOP = 11;
|
96
|
+
|
97
|
+
|
98
|
+
/* ----------------------------------------------------------------- *
|
99
|
+
* Code 93 symbology *
|
100
|
+
* ----------------------------------------------------------------- */
|
101
|
+
static const char *Code93[] = {
|
102
|
+
"131112", "111213", "111312", "111411", "121113", /* 0: 0 - 4 */
|
103
|
+
"121212", "121311", "111114", "131211", "141111", /* 5: 5 - 9 */
|
104
|
+
"211113", "211212", "211311", "221112", "221211", /* 10: A - E */
|
105
|
+
"231111", "112113", "112212", "112311", "122112", /* 15: F - J */
|
106
|
+
"132111", "111123", "111222", "111321", "121122", /* 20: K - O */
|
107
|
+
"131121", "212112", "212211", "211122", "211221", /* 25: P - T */
|
108
|
+
"221121", "222111", "112122", "112221", "122121", /* 30: U - Y */
|
109
|
+
"123111", "121131", "311112", "311211", "321111", /* 35: Z,-,.,SP,$ */
|
110
|
+
"112131", "113121", "211131", "131221", "312111", /* 40: /,+,%,($),(%) */
|
111
|
+
"311121", "122211", "111141" /* 45: (/),(+), Start */
|
112
|
+
};
|
113
|
+
|
114
|
+
/* Use "[]{}#" to represent special codes 43-47 */
|
115
|
+
static const char Code93Val[] =
|
116
|
+
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%[]{}#";
|
117
|
+
|
118
|
+
static const l_int32 C93_START = 47;
|
119
|
+
static const l_int32 C93_STOP = 47;
|
120
|
+
|
121
|
+
|
122
|
+
/* ----------------------------------------------------------------- *
|
123
|
+
* Code 39 symbology *
|
124
|
+
* ----------------------------------------------------------------- */
|
125
|
+
static const char *Code39[] = {
|
126
|
+
"111221211", "211211112", "112211112", "212211111", /* 0: 0 - 3 */
|
127
|
+
"111221112", "211221111", "112221111", "111211212", /* 4: 4 - 7 */
|
128
|
+
"211211211", "112211211", "211112112", "112112112", /* 8: 8 - B */
|
129
|
+
"212112111", "111122112", "211122111", "112122111", /* 12: C - F */
|
130
|
+
"111112212", "211112211", "112112211", "111122211", /* 16: G - J */
|
131
|
+
"211111122", "112111122", "212111121", "111121122", /* 20: K - N */
|
132
|
+
"211121121", "112121121", "111111222", "211111221", /* 24: O - R */
|
133
|
+
"112111221", "111121221", "221111112", "122111112", /* 28: S - V */
|
134
|
+
"222111111", "121121112", "221121111", "122121111", /* 32: W - Z */
|
135
|
+
"121111212", "221111211", "122111211", "121212111", /* 36: -,.,SP,$ */
|
136
|
+
"121211121", "121112121", "111212121", "121121211" /* 40: /,+,%,* */
|
137
|
+
};
|
138
|
+
|
139
|
+
/* Use "*" to represent the Start and Stop codes (43) */
|
140
|
+
static const char Code39Val[] =
|
141
|
+
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*";
|
142
|
+
|
143
|
+
static const l_int32 C39_START = 43;
|
144
|
+
static const l_int32 C39_STOP = 43;
|
145
|
+
|
146
|
+
|
147
|
+
/* ----------------------------------------------------------------- *
|
148
|
+
* Codabar symbology *
|
149
|
+
* ----------------------------------------------------------------- */
|
150
|
+
static const char *Codabar[] = {
|
151
|
+
"1111122", "1111221", "1112112", "2211111", "1121121", /* 0: 0 - 4 */
|
152
|
+
"2111121", "1211112", "1211211", "1221111", "2112111", /* 5: 5 - 9 */
|
153
|
+
"1112211", "1122111", "2111212", "2121112", "2121211", /* 10: -,$,:,/,. */
|
154
|
+
"1121212", "1122121", "1212112", "1112122", "1112221" /* 15: +,A,B,C,D */
|
155
|
+
};
|
156
|
+
|
157
|
+
/* Ascii representations for codes 16-19: (A or T), (B or N), (C or *),
|
158
|
+
* (D or E). These are used in pairs for the Start and Stop codes. */
|
159
|
+
static const char CodabarVal[] = "0123456789-$:/.+ABCD";
|
160
|
+
|
161
|
+
|
162
|
+
/* ----------------------------------------------------------------- *
|
163
|
+
* UPC-A symbology *
|
164
|
+
* ----------------------------------------------------------------- */
|
165
|
+
static const char *Upca[] = {
|
166
|
+
"3211", "2221", "2122", "1411", "1132", /* 0: 0 - 4 */
|
167
|
+
"1231", "1114", "1312", "1213", "3112", /* 5: 5 - 9 */
|
168
|
+
"111", "111", "11111" /* 10: Start, Stop, Mid */
|
169
|
+
};
|
170
|
+
|
171
|
+
static const l_int32 UPCA_START = 10;
|
172
|
+
static const l_int32 UPCA_STOP = 11;
|
173
|
+
static const l_int32 UPCA_MID = 12;
|
174
|
+
|
175
|
+
|
176
|
+
/* ----------------------------------------------------------------- *
|
177
|
+
* Code128 symbology *
|
178
|
+
* ----------------------------------------------------------------- */
|
179
|
+
static const char *Code128[] = {
|
180
|
+
"212222", "222122", "222221", "121223", "121322", /* 0 - 4 */
|
181
|
+
"131222", "122213", "122312", "132212", "221213", /* 5 - 9 */
|
182
|
+
"221312", "231212", "112232", "122132", "122231", /* 10 - 14 */
|
183
|
+
"113222", "123122", "123221", "223211", "221132", /* 15 - 19 */
|
184
|
+
"221231", "213212", "223112", "312131", "311222", /* 20 - 24 */
|
185
|
+
"321122", "321221", "312212", "322112", "322211", /* 25 - 29 */
|
186
|
+
"212123", "212321", "232121", "111323", "131123", /* 30 - 34 */
|
187
|
+
"131321", "112313", "132113", "132311", "211313", /* 35 - 39 */
|
188
|
+
"231113", "231311", "112133", "112331", "132131", /* 40 - 44 */
|
189
|
+
"113123", "113321", "133121", "313121", "211331", /* 45 - 49 */
|
190
|
+
"231131", "213113", "213311", "213131", "311123", /* 50 - 54 */
|
191
|
+
"311321", "331121", "312113", "312311", "332111", /* 55 - 59 */
|
192
|
+
"314111", "221411", "431111", "111224", "111422", /* 60 - 64 */
|
193
|
+
"121124", "121421", "141122", "141221", "112214", /* 65 - 69 */
|
194
|
+
"112412", "122114", "122411", "142112", "142211", /* 70 - 74 */
|
195
|
+
"241211", "221114", "413111", "241112", "134111", /* 75 - 79 */
|
196
|
+
"111242", "121142", "121241", "114212", "124112", /* 80 - 84 */
|
197
|
+
"124211", "411212", "421112", "421211", "212141", /* 85 - 89 */
|
198
|
+
"214121", "412121", "111143", "111341", "131141", /* 90 - 94 */
|
199
|
+
"114113", "114311", "411113", "411311", "113141", /* 95 - 99 */
|
200
|
+
"114131", "311141", "411131", "211412", "211214", /* 100 - 104 */
|
201
|
+
"211232", "2331112" /* 105 - 106 */
|
202
|
+
};
|
203
|
+
|
204
|
+
static const l_int32 C128_FUN_3 = 96; /* in A or B only; in C it is 96 */
|
205
|
+
static const l_int32 C128_FUNC_2 = 97; /* in A or B only; in C it is 97 */
|
206
|
+
static const l_int32 C128_SHIFT = 98; /* in A or B only; in C it is 98 */
|
207
|
+
static const l_int32 C128_GOTO_C = 99; /* in A or B only; in C it is 99 */
|
208
|
+
static const l_int32 C128_GOTO_B = 100;
|
209
|
+
static const l_int32 C128_GOTO_A = 101;
|
210
|
+
static const l_int32 C128_FUNC_1 = 102;
|
211
|
+
static const l_int32 C128_START_A = 103;
|
212
|
+
static const l_int32 C128_START_B = 104;
|
213
|
+
static const l_int32 C128_START_C = 105;
|
214
|
+
static const l_int32 C128_STOP = 106;
|
215
|
+
/* code 128 symbols are 11 units */
|
216
|
+
static const l_int32 C128_SYMBOL_WIDTH = 11;
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
#endif /* LEPTONICA_READBARCODE_H */
|
@@ -0,0 +1,122 @@
|
|
1
|
+
/*====================================================================*
|
2
|
+
- Copyright (C) 2001 Leptonica. All rights reserved.
|
3
|
+
- This software is distributed in the hope that it will be
|
4
|
+
- useful, but with NO WARRANTY OF ANY KIND.
|
5
|
+
- No author or distributor accepts responsibility to anyone for the
|
6
|
+
- consequences of using this software, or for whether it serves any
|
7
|
+
- particular purpose or works at all, unless he or she says so in
|
8
|
+
- writing. Everyone is granted permission to copy, modify and
|
9
|
+
- redistribute this source code, for commercial or non-commercial
|
10
|
+
- purposes, with the following restrictions: (1) the origin of this
|
11
|
+
- source code must not be misrepresented; (2) modified versions must
|
12
|
+
- be plainly marked as such; and (3) this notice may not be removed
|
13
|
+
- or altered from any source or modified source distribution.
|
14
|
+
*====================================================================*/
|
15
|
+
|
16
|
+
#ifndef LEPTONICA_REGUTILS_H
|
17
|
+
#define LEPTONICA_REGUTILS_H
|
18
|
+
|
19
|
+
/*
|
20
|
+
* regutils.h
|
21
|
+
*
|
22
|
+
* Contains this regression test parameter packaging struct
|
23
|
+
* struct L_RegParams
|
24
|
+
*
|
25
|
+
*
|
26
|
+
* The regression test utility allows you to write regression tests
|
27
|
+
* that compare results with existing "golden files".
|
28
|
+
*
|
29
|
+
* Such regression tests can be called in three ways.
|
30
|
+
* For example, for distance_reg:
|
31
|
+
*
|
32
|
+
* Case 1: distance_reg generate
|
33
|
+
* This generates golden files in /tmp for the reg test.
|
34
|
+
*
|
35
|
+
* Case 2: distance_reg compare
|
36
|
+
* This runs the test against the set of golden files. It
|
37
|
+
* appends to 'outfile.txt' either "SUCCESS" or "FAILURE",
|
38
|
+
* as well as the details of any parts of the test that failed.
|
39
|
+
* It writes to a temporary file stream (fp)
|
40
|
+
*
|
41
|
+
* Case 3: distance_reg [display]
|
42
|
+
* This runs the test but makes no comparison of the output
|
43
|
+
* against the set of golden files. In addition, this displays
|
44
|
+
* images and plots that are specified in the test under
|
45
|
+
* control of the display variable. Display is enabled only
|
46
|
+
* for this case. Using 'display' on the command line is optional.
|
47
|
+
*
|
48
|
+
* Regression tests follow the pattern given below. In an actual
|
49
|
+
* case, comparisons of pix and of files can occur in any order.
|
50
|
+
* We give a specific order here for clarity.
|
51
|
+
*
|
52
|
+
* L_REGPARAMS *rp; // holds data required by the test functions
|
53
|
+
*
|
54
|
+
* // Setup variables; optionally open stream
|
55
|
+
* if (regTestSetup(argc, argv, &rp))
|
56
|
+
* return 1;
|
57
|
+
*
|
58
|
+
* // Test pairs of generated pix for identity. This compares
|
59
|
+
* // two pix; no golden file is generated.
|
60
|
+
* regTestComparePix(rp, pix1, pix2);
|
61
|
+
*
|
62
|
+
* // Test pairs of generated pix for similarity. This compares
|
63
|
+
* // two pix; no golden file is generated. The last arg determines
|
64
|
+
* // if stats are to be written to stderr.
|
65
|
+
* regTestCompareSimilarPix(rp, pix1, pix2, 15, 0.001, 0);
|
66
|
+
*
|
67
|
+
* // Generation of <newfile*> outputs and testing for identity
|
68
|
+
* // These files can be anything, of course.
|
69
|
+
* regTestCheckFile(rp, <newfile0>);
|
70
|
+
* regTestCheckFile(rp, <newfile1>);
|
71
|
+
*
|
72
|
+
* // Test pairs of output golden files for identity. Here we
|
73
|
+
* // are comparing golden files 4 and 5.
|
74
|
+
* regTestCompareFiles(rp, 4, 5);
|
75
|
+
*
|
76
|
+
* // "Write and check". This writes a pix using a canonical
|
77
|
+
* // formulation for the local filename and either:
|
78
|
+
* // case 1: generates a golden file
|
79
|
+
* // case 2: compares the local file with a golden file
|
80
|
+
* // case 3: generates local files and displays
|
81
|
+
* // Here we write the pix compressed with png and jpeg, respectively;
|
82
|
+
* // Then check against the golden file. The internal @index
|
83
|
+
* // is incremented; it is embedded in the local filename and,
|
84
|
+
* // if generating, in the golden file as well.
|
85
|
+
* regTestWritePixAndCheck(rp, pix1, IFF_PNG);
|
86
|
+
* regTestWritePixAndCheck(rp, pix2, IFF_JFIF_JPEG);
|
87
|
+
*
|
88
|
+
* // Display if reg test was called in 'display' mode
|
89
|
+
* pixDisplayWithTitle(pix1, 100, 100, NULL, rp->display);
|
90
|
+
*
|
91
|
+
* // Clean up and output result
|
92
|
+
* regTestCleanup(rp);
|
93
|
+
*/
|
94
|
+
|
95
|
+
|
96
|
+
/*-------------------------------------------------------------------------*
|
97
|
+
* Regression test parameter packer *
|
98
|
+
*-------------------------------------------------------------------------*/
|
99
|
+
struct L_RegParams
|
100
|
+
{
|
101
|
+
FILE *fp; /* stream to temporary output file for compare mode */
|
102
|
+
char *testname; /* name of test, without '_reg' */
|
103
|
+
char *tempfile; /* name of temp file for compare mode output */
|
104
|
+
l_int32 mode; /* generate, compare or display */
|
105
|
+
l_int32 index; /* index into saved files for this test; 0-based */
|
106
|
+
l_int32 success; /* overall result of the test */
|
107
|
+
l_int32 display; /* 1 if in display mode; 0 otherwise */
|
108
|
+
L_TIMER tstart; /* marks beginning of the reg test */
|
109
|
+
};
|
110
|
+
typedef struct L_RegParams L_REGPARAMS;
|
111
|
+
|
112
|
+
|
113
|
+
/* Running modes for the test */
|
114
|
+
enum {
|
115
|
+
L_REG_GENERATE = 0,
|
116
|
+
L_REG_COMPARE = 1,
|
117
|
+
L_REG_DISPLAY = 2
|
118
|
+
};
|
119
|
+
|
120
|
+
|
121
|
+
#endif /* LEPTONICA_REGUTILS_H */
|
122
|
+
|