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,23 @@
|
|
1
|
+
/*====================================================================*
|
2
|
+
- Copyright (C) 2008 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_FREETYPE_H
|
17
|
+
#define LEPTONICA_FREETYPE_H
|
18
|
+
|
19
|
+
#define LEPTONICA_FT_RESOLUTION 96
|
20
|
+
|
21
|
+
typedef struct ft_library_st FT_LIBRARY;
|
22
|
+
|
23
|
+
#endif /* LEPTONICA_FREETYPE_H */
|
@@ -0,0 +1,77 @@
|
|
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_GPLOT_H
|
17
|
+
#define LEPTONICA_GPLOT_H
|
18
|
+
|
19
|
+
/*
|
20
|
+
* gplot.h
|
21
|
+
*
|
22
|
+
* Data structures and parameters for generating gnuplot files
|
23
|
+
*/
|
24
|
+
|
25
|
+
#define GPLOT_VERSION_NUMBER 1
|
26
|
+
|
27
|
+
#define NUM_GPLOT_STYLES 5
|
28
|
+
enum GPLOT_STYLE {
|
29
|
+
GPLOT_LINES = 0,
|
30
|
+
GPLOT_POINTS = 1,
|
31
|
+
GPLOT_IMPULSES = 2,
|
32
|
+
GPLOT_LINESPOINTS = 3,
|
33
|
+
GPLOT_DOTS = 4
|
34
|
+
};
|
35
|
+
|
36
|
+
#define NUM_GPLOT_OUTPUTS 6
|
37
|
+
enum GPLOT_OUTPUT {
|
38
|
+
GPLOT_NONE = 0,
|
39
|
+
GPLOT_PNG = 1,
|
40
|
+
GPLOT_PS = 2,
|
41
|
+
GPLOT_EPS = 3,
|
42
|
+
GPLOT_X11 = 4,
|
43
|
+
GPLOT_LATEX = 5
|
44
|
+
};
|
45
|
+
|
46
|
+
enum GPLOT_SCALING {
|
47
|
+
GPLOT_LINEAR_SCALE = 0, /* default */
|
48
|
+
GPLOT_LOG_SCALE_X = 1,
|
49
|
+
GPLOT_LOG_SCALE_Y = 2,
|
50
|
+
GPLOT_LOG_SCALE_X_Y = 3
|
51
|
+
};
|
52
|
+
|
53
|
+
extern const char *gplotstylenames[]; /* used in gnuplot cmd file */
|
54
|
+
extern const char *gplotfilestyles[]; /* used in simple file input */
|
55
|
+
extern const char *gplotfileoutputs[]; /* used in simple file input */
|
56
|
+
|
57
|
+
struct GPlot
|
58
|
+
{
|
59
|
+
char *rootname; /* for cmd, data, output */
|
60
|
+
char *cmdname; /* command file name */
|
61
|
+
struct Sarray *cmddata; /* command file contents */
|
62
|
+
struct Sarray *datanames; /* data file names */
|
63
|
+
struct Sarray *plotdata; /* plot data (1 string/file) */
|
64
|
+
struct Sarray *plottitles; /* title for each individual plot */
|
65
|
+
struct Numa *plotstyles; /* plot style for individual plots */
|
66
|
+
l_int32 nplots; /* current number of plots */
|
67
|
+
char *outname; /* output file name */
|
68
|
+
l_int32 outformat; /* GPLOT_OUTPUT values */
|
69
|
+
l_int32 scaling; /* GPLOT_SCALING values */
|
70
|
+
char *title; /* optional */
|
71
|
+
char *xlabel; /* optional x axis label */
|
72
|
+
char *ylabel; /* optional y axis label */
|
73
|
+
};
|
74
|
+
typedef struct GPlot GPLOT;
|
75
|
+
|
76
|
+
|
77
|
+
#endif /* LEPTONICA_GPLOT_H */
|
@@ -0,0 +1,73 @@
|
|
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_HEAP_H
|
17
|
+
#define LEPTONICA_HEAP_H
|
18
|
+
|
19
|
+
/*
|
20
|
+
* heap.h
|
21
|
+
*
|
22
|
+
* Expandable priority queue configured as a heap for arbitrary void* data
|
23
|
+
*
|
24
|
+
* The L_Heap is used to implement a priority queue. The elements
|
25
|
+
* in the heap are ordered in either increasing or decreasing key value.
|
26
|
+
* The key is a float field 'keyval' that is required to be
|
27
|
+
* contained in the elements of the queue.
|
28
|
+
*
|
29
|
+
* The heap is a simple binary tree with the following constraints:
|
30
|
+
* - the key of each node is >= the keys of the two children
|
31
|
+
* - the tree is complete, meaning that each level (1, 2, 4, ...)
|
32
|
+
* is filled and the last level is filled from left to right
|
33
|
+
*
|
34
|
+
* The tree structure is implicit in the queue array, with the
|
35
|
+
* array elements numbered as a breadth-first search of the tree
|
36
|
+
* from left to right. It is thus guaranteed that the largest
|
37
|
+
* (or smallest) key belongs to the first element in the array.
|
38
|
+
*
|
39
|
+
* Heap sort is used to sort the array. Once an array has been
|
40
|
+
* sorted as a heap, it is convenient to use it as a priority queue,
|
41
|
+
* because the min (or max) elements are always at the root of
|
42
|
+
* the tree (element 0), and once removed, the heap can be
|
43
|
+
* resorted in not more than log[n] steps, where n is the number
|
44
|
+
* of elements on the heap. Likewise, if an arbitrary element is
|
45
|
+
* added to the end of the array A, the sorted heap can be restored
|
46
|
+
* in not more than log[n] steps.
|
47
|
+
*
|
48
|
+
* A L_Heap differs from a L_Queue in that the elements in the former
|
49
|
+
* are sorted by a key. Internally, the array is maintained
|
50
|
+
* as a queue, with a pointer to the end of the array. The
|
51
|
+
* head of the array always remains at array[0]. The array is
|
52
|
+
* maintained (sorted) as a heap. When an item is removed from
|
53
|
+
* the head, the last item takes its place (thus reducing the
|
54
|
+
* array length by 1), and this is followed by array element
|
55
|
+
* swaps to restore the heap property. When an item is added,
|
56
|
+
* it goes at the end of the array, and is swapped up to restore
|
57
|
+
* the heap. If the ptr array is full, adding another item causes
|
58
|
+
* the ptr array size to double.
|
59
|
+
*
|
60
|
+
* For further implementation details, see heap.c.
|
61
|
+
*/
|
62
|
+
|
63
|
+
struct L_Heap
|
64
|
+
{
|
65
|
+
l_int32 nalloc; /* size of allocated ptr array */
|
66
|
+
l_int32 n; /* number of elements stored in the heap */
|
67
|
+
void **array; /* ptr array */
|
68
|
+
l_int32 direction; /* L_SORT_INCREASING or L_SORT_DECREASING */
|
69
|
+
};
|
70
|
+
typedef struct L_Heap L_HEAP;
|
71
|
+
|
72
|
+
|
73
|
+
#endif /* LEPTONICA_HEAP_H */
|
@@ -0,0 +1,153 @@
|
|
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_IMAGEIO_H
|
17
|
+
#define LEPTONICA_IMAGEIO_H
|
18
|
+
|
19
|
+
/* ------------------ Image file format types -------------- */
|
20
|
+
/*
|
21
|
+
* The IFF_DEFAULT flag is used to write the file out in the
|
22
|
+
* same (input) file format that the pix was read from. If the pix
|
23
|
+
* was not read from file, the input format field will be
|
24
|
+
* IFF_UNKNOWN and the output file format will be chosen to
|
25
|
+
* be compressed and lossless; namely, IFF_TIFF_G4 for d = 1
|
26
|
+
* and IFF_PNG for everything else. IFF_JP2 is for jpeg2000, which
|
27
|
+
* is not supported in leptonica.
|
28
|
+
*
|
29
|
+
* In the future, new format types that have defined extensions
|
30
|
+
* will be added before IFF_DEFAULT, and will be kept in sync with
|
31
|
+
* the file format extensions in writefile.c. The positions of
|
32
|
+
* file formats before IFF_DEFAULT will remain invariant.
|
33
|
+
*/
|
34
|
+
enum {
|
35
|
+
IFF_UNKNOWN = 0,
|
36
|
+
IFF_BMP = 1,
|
37
|
+
IFF_JFIF_JPEG = 2,
|
38
|
+
IFF_PNG = 3,
|
39
|
+
IFF_TIFF = 4,
|
40
|
+
IFF_TIFF_PACKBITS = 5,
|
41
|
+
IFF_TIFF_RLE = 6,
|
42
|
+
IFF_TIFF_G3 = 7,
|
43
|
+
IFF_TIFF_G4 = 8,
|
44
|
+
IFF_TIFF_LZW = 9,
|
45
|
+
IFF_TIFF_ZIP = 10,
|
46
|
+
IFF_PNM = 11,
|
47
|
+
IFF_PS = 12,
|
48
|
+
IFF_GIF = 13,
|
49
|
+
IFF_JP2 = 14,
|
50
|
+
IFF_WEBP = 15,
|
51
|
+
IFF_LPDF = 16,
|
52
|
+
IFF_DEFAULT = 17,
|
53
|
+
IFF_SPIX = 18
|
54
|
+
};
|
55
|
+
|
56
|
+
|
57
|
+
/* ---------------------- Format header ids --------------------- */
|
58
|
+
enum {
|
59
|
+
BMP_ID = 0x4d42,
|
60
|
+
TIFF_BIGEND_ID = 0x4d4d, /* MM - for 'motorola' */
|
61
|
+
TIFF_LITTLEEND_ID = 0x4949 /* II - for 'intel' */
|
62
|
+
};
|
63
|
+
|
64
|
+
|
65
|
+
/* ------------------ Gray hinting in jpeg reader --------------- */
|
66
|
+
enum {
|
67
|
+
L_HINT_GRAY = 1, /* only want grayscale information */
|
68
|
+
};
|
69
|
+
|
70
|
+
|
71
|
+
/* ------------------ Pdf formated encoding types --------------- */
|
72
|
+
enum {
|
73
|
+
L_JPEG_ENCODE = 1, /* use dct encoding: 8 and 32 bpp, no cmap */
|
74
|
+
L_G4_ENCODE = 2, /* use ccitt g4 fax encoding: 1 bpp */
|
75
|
+
L_FLATE_ENCODE = 3 /* use flate encoding: any depth, cmap ok */
|
76
|
+
};
|
77
|
+
|
78
|
+
|
79
|
+
/* ------------------ Compressed image data --------------------- */
|
80
|
+
/*
|
81
|
+
* In use, either datacomp or data85 will be produced, depending
|
82
|
+
* on whether the data needs to be ascii85 encoded. PostScript
|
83
|
+
* requires ascii85 encoding; pdf does not.
|
84
|
+
*
|
85
|
+
* For the colormap (flate compression only), PostScript uses ascii85
|
86
|
+
* encoding and pdf uses a bracketed array of space-separated
|
87
|
+
* hex-encoded rgb triples. Only tiff g4 (type == L_G4_ENCODE) uses
|
88
|
+
* the minisblack field.
|
89
|
+
*/
|
90
|
+
struct L_Compressed_Data
|
91
|
+
{
|
92
|
+
l_int32 type; /* encoding type: L_JPEG_ENCODE, etc */
|
93
|
+
l_uint8 *datacomp; /* gzipped raster data */
|
94
|
+
size_t nbytescomp; /* number of compressed bytes */
|
95
|
+
char *data85; /* ascii85-encoded gzipped raster data */
|
96
|
+
size_t nbytes85; /* number of ascii85 encoded bytes */
|
97
|
+
char *cmapdata85; /* ascii85-encoded uncompressed cmap */
|
98
|
+
char *cmapdatahex; /* hex pdf array for the cmap */
|
99
|
+
l_int32 ncolors; /* number of colors in cmap */
|
100
|
+
l_int32 w; /* image width */
|
101
|
+
l_int32 h; /* image height */
|
102
|
+
l_int32 bps; /* bits/sample; typ. 1, 2, 4 or 8 */
|
103
|
+
l_int32 spp; /* samples/pixel; typ. 1 or 3 */
|
104
|
+
l_int32 minisblack; /* tiff g4 photometry */
|
105
|
+
size_t nbytes; /* number of uncompressed raster bytes */
|
106
|
+
l_int32 res; /* resolution (ppi) */
|
107
|
+
};
|
108
|
+
typedef struct L_Compressed_Data L_COMPRESSED_DATA;
|
109
|
+
|
110
|
+
|
111
|
+
/* ------------------------ Pdf multi-image flags ------------------------ */
|
112
|
+
enum {
|
113
|
+
L_FIRST_IMAGE = 1, /* first image to be used */
|
114
|
+
L_NEXT_IMAGE = 2, /* intermediate image; not first or last */
|
115
|
+
L_LAST_IMAGE = 3 /* last image to be used */
|
116
|
+
};
|
117
|
+
|
118
|
+
|
119
|
+
/* ------------------ Intermediate pdf generation data -------------------- */
|
120
|
+
/*
|
121
|
+
* This accumulates data for generating a pdf of a single page consisting
|
122
|
+
* of an arbitrary number of images.
|
123
|
+
*
|
124
|
+
* None of the strings have a trailing newline.
|
125
|
+
*/
|
126
|
+
struct L_Pdf_Data
|
127
|
+
{
|
128
|
+
char *title; /* optional title for pdf */
|
129
|
+
l_int32 n; /* number of images */
|
130
|
+
l_int32 ncmap; /* number of colormaps */
|
131
|
+
struct L_Ptra *cida; /* array of compressed image data */
|
132
|
+
char *id; /* %PDF-1.2 id string */
|
133
|
+
char *obj1; /* catalog string */
|
134
|
+
char *obj2; /* metadata string */
|
135
|
+
char *obj3; /* pages string */
|
136
|
+
char *obj4; /* page string (variable data) */
|
137
|
+
char *obj5; /* content string (variable data) */
|
138
|
+
char *poststream; /* post-binary-stream string */
|
139
|
+
char *trailer; /* trailer string (variable data) */
|
140
|
+
struct Pta *xy; /* store (xpt, ypt) array */
|
141
|
+
struct Pta *wh; /* store (wpt, hpt) array */
|
142
|
+
struct Box *mediabox; /* bounding region for all images */
|
143
|
+
struct Sarray *saprex; /* pre-binary-stream xobject strings */
|
144
|
+
struct Sarray *sacmap; /* colormap pdf object strings */
|
145
|
+
struct Numa *objsize; /* sizes of each pdf string object */
|
146
|
+
struct Numa *objloc; /* location of each pdf string object */
|
147
|
+
l_int32 xrefloc; /* location of xref */
|
148
|
+
};
|
149
|
+
typedef struct L_Pdf_Data L_PDF_DATA;
|
150
|
+
|
151
|
+
|
152
|
+
#endif /* LEPTONICA_IMAGEIO_H */
|
153
|
+
|
@@ -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_JBCLASS_H
|
17
|
+
#define LEPTONICA_JBCLASS_H
|
18
|
+
|
19
|
+
/*
|
20
|
+
* jbclass.h
|
21
|
+
*
|
22
|
+
* JbClasser
|
23
|
+
* JbData
|
24
|
+
*/
|
25
|
+
|
26
|
+
|
27
|
+
/* The JbClasser struct holds all the data accumulated during the
|
28
|
+
* classification process that can be used for a compressed
|
29
|
+
* jbig2-type representation of a set of images. This is created
|
30
|
+
* in an initialization process and added to as the selected components
|
31
|
+
* on each successive page are analyzed. */
|
32
|
+
struct JbClasser
|
33
|
+
{
|
34
|
+
struct Sarray *safiles; /* input page image file names */
|
35
|
+
l_int32 method; /* JB_RANKHAUS, JB_CORRELATION */
|
36
|
+
l_int32 components; /* JB_CONN_COMPS, JB_CHARACTERS or */
|
37
|
+
/* JB_WORDS */
|
38
|
+
l_int32 maxwidth; /* max component width allowed */
|
39
|
+
l_int32 maxheight; /* max component height allowed */
|
40
|
+
l_int32 npages; /* number of pages already processed */
|
41
|
+
l_int32 baseindex; /* number of components already processed */
|
42
|
+
/* on fully processed pages */
|
43
|
+
struct Numa *nacomps; /* number of components on each page */
|
44
|
+
l_int32 sizehaus; /* size of square struct element for haus */
|
45
|
+
l_float32 rankhaus; /* rank val of haus match, each way */
|
46
|
+
l_float32 thresh; /* thresh value for correlation score */
|
47
|
+
l_float32 weightfactor; /* corrects thresh value for heaver */
|
48
|
+
/* components; use 0 for no correction */
|
49
|
+
struct Numa *naarea; /* w * h of each template, without extra */
|
50
|
+
/* border pixels */
|
51
|
+
l_int32 w; /* max width of original src images */
|
52
|
+
l_int32 h; /* max height of original src images */
|
53
|
+
l_int32 nclass; /* current number of classes */
|
54
|
+
l_int32 keep_pixaa; /* If zero, pixaa isn't filled */
|
55
|
+
struct Pixaa *pixaa; /* instances for each class; unbordered */
|
56
|
+
struct Pixa *pixat; /* templates for each class; bordered */
|
57
|
+
/* and not dilated */
|
58
|
+
struct Pixa *pixatd; /* templates for each class; bordered */
|
59
|
+
/* and dilated */
|
60
|
+
struct NumaHash *nahash; /* Hash table to find templates by size */
|
61
|
+
struct Numa *nafgt; /* fg areas of undilated templates; */
|
62
|
+
/* only used for rank < 1.0 */
|
63
|
+
struct Pta *ptac; /* centroids of all bordered cc */
|
64
|
+
struct Pta *ptact; /* centroids of all bordered template cc */
|
65
|
+
struct Numa *naclass; /* array of class ids for each component */
|
66
|
+
struct Numa *napage; /* array of page nums for each component */
|
67
|
+
struct Pta *ptaul; /* array of UL corners at which the */
|
68
|
+
/* template is to be placed for each */
|
69
|
+
/* component */
|
70
|
+
struct Pta *ptall; /* similar to ptaul, but for LL corners */
|
71
|
+
};
|
72
|
+
typedef struct JbClasser JBCLASSER;
|
73
|
+
|
74
|
+
|
75
|
+
/* The JbData struct holds all the data required for
|
76
|
+
* the compressed jbig-type representation of a set of images.
|
77
|
+
* The data can be written to file, read back, and used
|
78
|
+
* to regenerate an approximate version of the original,
|
79
|
+
* which differs in two ways from the original:
|
80
|
+
* (1) It uses a template image for each c.c. instead of the
|
81
|
+
* original instance, for each occurrence on each page.
|
82
|
+
* (2) It discards components with either a height or width larger
|
83
|
+
* than the maximuma, given here by the lattice dimensions
|
84
|
+
* used for storing the templates. */
|
85
|
+
struct JbData
|
86
|
+
{
|
87
|
+
struct Pix *pix; /* template composite for all classes */
|
88
|
+
l_int32 npages; /* number of pages */
|
89
|
+
l_int32 w; /* max width of original page images */
|
90
|
+
l_int32 h; /* max height of original page images */
|
91
|
+
l_int32 nclass; /* number of classes */
|
92
|
+
l_int32 latticew; /* lattice width for template composite */
|
93
|
+
l_int32 latticeh; /* lattice height for template composite */
|
94
|
+
struct Numa *naclass; /* array of class ids for each component */
|
95
|
+
struct Numa *napage; /* array of page nums for each component */
|
96
|
+
struct Pta *ptaul; /* array of UL corners at which the */
|
97
|
+
/* template is to be placed for each */
|
98
|
+
/* component */
|
99
|
+
};
|
100
|
+
typedef struct JbData JBDATA;
|
101
|
+
|
102
|
+
|
103
|
+
/* Classifier methods */
|
104
|
+
enum {
|
105
|
+
JB_RANKHAUS = 0,
|
106
|
+
JB_CORRELATION = 1
|
107
|
+
};
|
108
|
+
|
109
|
+
/* For jbGetComponents(): type of component to extract from images */
|
110
|
+
enum {
|
111
|
+
JB_CONN_COMPS = 0,
|
112
|
+
JB_CHARACTERS = 1,
|
113
|
+
JB_WORDS = 2
|
114
|
+
};
|
115
|
+
|
116
|
+
/* These parameters are used for naming the two files
|
117
|
+
* in which the jbig2-like compressed data is stored. */
|
118
|
+
#define JB_TEMPLATE_EXT ".templates.png"
|
119
|
+
#define JB_DATA_EXT ".data"
|
120
|
+
|
121
|
+
|
122
|
+
#endif /* LEPTONICA_JBCLASS_H */
|