motion-ocr 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +10 -0
  4. data/LICENSE +28 -0
  5. data/README.md +22 -0
  6. data/Rakefile +17 -0
  7. data/app/app_delegate.rb +2 -0
  8. data/lib/motion-ocr.rb +26 -0
  9. data/lib/motion-ocr/version.rb +3 -0
  10. data/motion-ocr.gemspec +20 -0
  11. data/resources/tessdata/configs/nodict +3 -0
  12. data/resources/tessdata/eng.traineddata +0 -0
  13. data/spec/motion_ocr_spec.rb +23 -0
  14. data/spec/support/phototest.gif +0 -0
  15. data/vendor/MotionOCR/MotionOCR.bridgesupport +14722 -0
  16. data/vendor/MotionOCR/MotionOCR.xcodeproj/project.pbxproj +390 -0
  17. data/vendor/MotionOCR/MotionOCR.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  18. data/vendor/MotionOCR/MotionOCR.xcodeproj/project.xcworkspace/xcuserdata/fer.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  19. data/vendor/MotionOCR/MotionOCR.xcodeproj/xcuserdata/fer.xcuserdatad/xcschemes/MotionOCR.xcscheme +59 -0
  20. data/vendor/MotionOCR/MotionOCR.xcodeproj/xcuserdata/fer.xcuserdatad/xcschemes/xcschememanagement.plist +22 -0
  21. data/vendor/MotionOCR/MotionOCR/MotionOCR-Prefix.pch +7 -0
  22. data/vendor/MotionOCR/MotionOCR/MotionOCR.h +22 -0
  23. data/vendor/MotionOCR/MotionOCR/MotionOCR.mm +89 -0
  24. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/allheaders.h +32 -0
  25. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/alltypes.h +49 -0
  26. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/array.h +125 -0
  27. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/arrayaccess.h +194 -0
  28. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/bbuffer.h +46 -0
  29. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/bmf.h +51 -0
  30. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/bmp.h +74 -0
  31. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/ccbord.h +103 -0
  32. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/dewarp.h +57 -0
  33. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/endianness.h +11 -0
  34. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/environ.h +281 -0
  35. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/freetype.h +23 -0
  36. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/gplot.h +77 -0
  37. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/heap.h +73 -0
  38. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/imageio.h +153 -0
  39. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/jbclass.h +122 -0
  40. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/leptprotos.h +2058 -0
  41. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/leptwin.h +34 -0
  42. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/list.h +76 -0
  43. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/morph.h +218 -0
  44. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/pix.h +945 -0
  45. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/ptra.h +80 -0
  46. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/queue.h +63 -0
  47. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/readbarcode.h +220 -0
  48. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/regutils.h +122 -0
  49. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/stack.h +55 -0
  50. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/sudoku.h +62 -0
  51. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/watershed.h +52 -0
  52. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/apitypes.h +31 -0
  53. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/baseapi.h +664 -0
  54. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/errcode.h +104 -0
  55. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/genericvector.h +763 -0
  56. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/helpers.h +139 -0
  57. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/host.h +180 -0
  58. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/ndminx.h +31 -0
  59. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/ocrclass.h +335 -0
  60. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/platform.h +48 -0
  61. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/publictypes.h +202 -0
  62. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/tesscallback.h +1238 -0
  63. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/thresholder.h +170 -0
  64. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/unichar.h +85 -0
  65. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/lib/liblept.a +0 -0
  66. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/lib/libtesseract_all.a +0 -0
  67. metadata +113 -0
@@ -0,0 +1,46 @@
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_BBUFFER_H
17
+ #define LEPTONICA_BBUFFER_H
18
+
19
+ /*
20
+ * bbuffer.h
21
+ *
22
+ * Expandable byte buffer for reading data in from memory and
23
+ * writing data out to other memory.
24
+ *
25
+ * This implements a queue of bytes, so data read in is put
26
+ * on the "back" of the queue (i.e., the end of the byte array)
27
+ * and data written out is taken from the "front" of the queue
28
+ * (i.e., from an index marker "nwritten" that is initially set at
29
+ * the beginning of the array.) As usual with expandable
30
+ * arrays, we keep the size of the allocated array and the
31
+ * number of bytes that have been read into the array.
32
+ *
33
+ * For implementation details, see bbuffer.c.
34
+ */
35
+
36
+ struct ByteBuffer
37
+ {
38
+ l_int32 nalloc; /* size of allocated byte array */
39
+ l_int32 n; /* number of bytes read into to the array */
40
+ l_int32 nwritten; /* number of bytes written from the array */
41
+ l_uint8 *array; /* byte array */
42
+ };
43
+ typedef struct ByteBuffer BBUFFER;
44
+
45
+
46
+ #endif /* LEPTONICA_BBUFFER_H */
@@ -0,0 +1,51 @@
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_BMF_H
17
+ #define LEPTONICA_BMF_H
18
+
19
+ /*
20
+ * bmf.h
21
+ *
22
+ * Simple data structure to hold bitmap fonts and related data
23
+ */
24
+
25
+ /* Constants for deciding when text block is divided into paragraphs */
26
+ enum {
27
+ SPLIT_ON_LEADING_WHITE = 1, /* tab or space at beginning of line */
28
+ SPLIT_ON_BLANK_LINE = 2, /* newline with optional white space */
29
+ SPLIT_ON_BOTH = 3 /* leading white space or newline */
30
+ };
31
+
32
+
33
+ struct L_Bmf
34
+ {
35
+ struct Pixa *pixa; /* pixa of bitmaps for 93 characters */
36
+ l_int32 size; /* font size (in points at 300 ppi) */
37
+ char *directory; /* directory containing font bitmaps */
38
+ l_int32 baseline1; /* baseline offset for ascii 33 - 57 */
39
+ l_int32 baseline2; /* baseline offset for ascii 58 - 91 */
40
+ l_int32 baseline3; /* baseline offset for ascii 93 - 126 */
41
+ l_int32 lineheight; /* max height of line of chars */
42
+ l_int32 kernwidth; /* pixel dist between char bitmaps */
43
+ l_int32 spacewidth; /* pixel dist between word bitmaps */
44
+ l_int32 vertlinesep; /* extra vertical space between text lines */
45
+ l_int32 *fonttab; /* table mapping ascii --> font index */
46
+ l_int32 *baselinetab; /* table mapping ascii --> baseline offset */
47
+ l_int32 *widthtab; /* table mapping ascii --> char width */
48
+ };
49
+ typedef struct L_Bmf L_BMF;
50
+
51
+ #endif /* LEPTONICA_BMF_H */
@@ -0,0 +1,74 @@
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_BMP_H
17
+ #define LEPTONICA_BMP_H
18
+
19
+ /*
20
+ * This file is here to describe the fields in the header of
21
+ * the BMP file. These fields are not used directly in Leptonica.
22
+ * The only thing we use are the sizes of these two headers.
23
+ * Furthermore, because of potential namespace conflicts with
24
+ * the typedefs and defined sizes, we have changed the names
25
+ * to protect anyone who may also need to use the original definitions.
26
+ * Thanks to J. D. Bryan for pointing out the potential problems when
27
+ * developing on Win32 compatible systems.
28
+ */
29
+
30
+ /*-------------------------------------------------------------*
31
+ * BMP file header *
32
+ *-------------------------------------------------------------*/
33
+ struct BMP_FileHeader
34
+ {
35
+ l_int16 bfType; /* file type; must be "BM" */
36
+ l_int16 bfSize; /* length of the file;
37
+ sizeof(BMP_FileHeader) +
38
+ sizeof(BMP_InfoHeader) +
39
+ size of color table +
40
+ size of DIB bits */
41
+ l_int16 bfFill1; /* remainder of the bfSize field */
42
+ l_int16 bfReserved1; /* don't care (set to 0)*/
43
+ l_int16 bfReserved2; /* don't care (set to 0)*/
44
+ l_int16 bfOffBits; /* offset from beginning of file */
45
+ l_int16 bfFill2; /* remainder of the bfOffBits field */
46
+ };
47
+ typedef struct BMP_FileHeader BMP_FH;
48
+
49
+ #define BMP_FHBYTES sizeof(BMP_FH)
50
+
51
+
52
+ /*-------------------------------------------------------------*
53
+ * BMP info header *
54
+ *-------------------------------------------------------------*/
55
+ struct BMP_InfoHeader
56
+ {
57
+ l_int32 biSize; /* size of the BMP_InfoHeader struct */
58
+ l_int32 biWidth; /* bitmap width in pixels */
59
+ l_int32 biHeight; /* bitmap height in pixels */
60
+ l_int16 biPlanes; /* number of bitmap planes */
61
+ l_int16 biBitCount; /* number of bits per pixel */
62
+ l_int32 biCompression; /* compression format (0 == uncompressed) */
63
+ l_int32 biSizeImage; /* size of image in bytes */
64
+ l_int32 biXPelsPerMeter; /* pixels per meter in x direction */
65
+ l_int32 biYPelsPerMeter; /* pixels per meter in y direction */
66
+ l_int32 biClrUsed; /* number of colors used */
67
+ l_int32 biClrImportant; /* number of important colors used */
68
+ };
69
+ typedef struct BMP_InfoHeader BMP_IH;
70
+
71
+ #define BMP_IHBYTES sizeof(BMP_IH)
72
+
73
+
74
+ #endif /* LEPTONICA_BMP_H */
@@ -0,0 +1,103 @@
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_CCBORD_H
17
+ #define LEPTONICA_CCBORD_H
18
+
19
+ /*
20
+ * ccbord.h
21
+ *
22
+ * CCBord: represents a single connected component
23
+ * CCBorda: an array of CCBord
24
+ */
25
+
26
+ /* Use in ccbaStepChainsToPixCoords() */
27
+ enum {
28
+ CCB_LOCAL_COORDS = 1,
29
+ CCB_GLOBAL_COORDS = 2
30
+ };
31
+
32
+ /* Use in ccbaGenerateSPGlobalLocs() */
33
+ enum {
34
+ CCB_SAVE_ALL_PTS = 1,
35
+ CCB_SAVE_TURNING_PTS = 2
36
+ };
37
+
38
+
39
+ /* CCBord contains:
40
+ *
41
+ * (1) a minimally-clipped bitmap of the component (pix),
42
+ * (2) a boxa consisting of:
43
+ * for the primary component:
44
+ * (xul, yul) pixel location in global coords
45
+ * (w, h) of the bitmap
46
+ * for the hole components:
47
+ * (x, y) in relative coordinates in primary component
48
+ * (w, h) of the hole border (which is 2 pixels
49
+ * larger in each direction than the hole itself)
50
+ * (3) a pta ('start') of the initial border pixel location for each
51
+ * closed curve, all in relative coordinates of the primary
52
+ * component. This is given for the primary component,
53
+ * followed by the hole components, if any.
54
+ * (4) a refcount of the ccbord; used internally when a ccbord
55
+ * is accessed from a ccborda (array of ccbord)
56
+ * (5) a ptaa for the chain code for the border in relative
57
+ * coordinates, where the first pta is the exterior border
58
+ * and all other pta are for interior borders (holes)
59
+ * (6) a ptaa for the global pixel loc rendition of the border,
60
+ * where the first pta is the exterior border and all other
61
+ * pta are for interior borders (holes).
62
+ * This is derived from the local or step chain code.
63
+ * (7) a numaa for the chain code for the border as orientation
64
+ * directions between successive border pixels, where
65
+ * the first numa is the exterior border and all other
66
+ * numa are for interior borders (holes). This is derived
67
+ * from the local chain code. The 8 directions are 0 - 7.
68
+ * (8) a pta for a single chain for each c.c., comprised of outer
69
+ * and hole borders, plus cut paths between them, all in
70
+ * local coords.
71
+ * (9) a pta for a single chain for each c.c., comprised of outer
72
+ * and hole borders, plus cut paths between them, all in
73
+ * global coords.
74
+ */
75
+ struct CCBord
76
+ {
77
+ struct Pix *pix; /* component bitmap (min size) */
78
+ struct Boxa *boxa; /* regions of each closed curve */
79
+ struct Pta *start; /* initial border pixel locations */
80
+ l_int32 refcount; /* number of handles; start at 1 */
81
+ struct Ptaa *local; /* ptaa of chain pixels (local) */
82
+ struct Ptaa *global; /* ptaa of chain pixels (global) */
83
+ struct Numaa *step; /* numaa of chain code (step dir) */
84
+ struct Pta *splocal; /* pta of single chain (local) */
85
+ struct Pta *spglobal; /* pta of single chain (global) */
86
+ };
87
+ typedef struct CCBord CCBORD;
88
+
89
+
90
+ struct CCBorda
91
+ {
92
+ struct Pix *pix; /* input pix (may be null) */
93
+ l_int32 w; /* width of pix */
94
+ l_int32 h; /* height of pix */
95
+ l_int32 n; /* number of ccbord in ptr array */
96
+ l_int32 nalloc; /* number of ccbord ptrs allocated */
97
+ struct CCBord **ccb; /* ccb ptr array */
98
+ };
99
+ typedef struct CCBorda CCBORDA;
100
+
101
+
102
+ #endif /* LEPTONICA_CCBORD_H */
103
+
@@ -0,0 +1,57 @@
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_DEWARP_H
17
+ #define LEPTONICA_DEWARP_H
18
+
19
+ /*
20
+ * dewarp.h
21
+ *
22
+ * Data structure to hold arrays and results for generating
23
+ * a vertical disparity array based on textlines. The disparity
24
+ * array is two-dimensional, and it represents a vertical
25
+ * displacement, relative to the flat point in the textlines.
26
+ * After dewarping, all points on the altered curve will have
27
+ * a y-value equal to the flat point.
28
+ *
29
+ * The sampled vertical disparity array is expanded to full resolution,
30
+ * using linear interpolation, from which it is trivially applied
31
+ * to the input image.
32
+ */
33
+
34
+ #define DEWARP_VERSION_NUMBER 1
35
+
36
+ struct L_Dewarp
37
+ {
38
+ struct Pix *pixs; /* source pix, 1 bpp */
39
+ struct Pix *pixd; /* dewarped pix; 1, 8 or 32 bpp */
40
+ struct FPix *sampvdispar; /* sampled vertical disparity array */
41
+ struct FPix *samphdispar; /* sampled horizontal disparity array */
42
+ struct FPix *fullvdispar; /* full vertical disparity array */
43
+ struct FPix *fullhdispar; /* full horiztontal disparity array */
44
+ struct Numa *naflats; /* sorted flat location of each line */
45
+ struct Numa *nacurves; /* sorted curvature of each line */
46
+ l_int32 pageno; /* page number; important for reuse */
47
+ l_int32 sampling; /* sampling factor of disparity array */
48
+ l_int32 minlines; /* min number of long lines required */
49
+ l_int32 applyhoriz; /* flag for estimating horiz. disparity */
50
+ l_int32 nx; /* number of sampling pts in x direction */
51
+ l_int32 ny; /* number of sampling pts in y direction */
52
+ l_int32 extraw; /* extra width required for hor. disparity */
53
+ l_int32 success; /* sets to 1 if model build succeeds */
54
+ };
55
+ typedef struct L_Dewarp L_DEWARP;
56
+
57
+ #endif /* LEPTONICA_DEWARP_H */
@@ -0,0 +1,11 @@
1
+ #if !defined (L_BIG_ENDIAN) && !defined (L_LITTLE_ENDIAN)
2
+ # if 0
3
+ # ifdef __BIG_ENDIAN__
4
+ # define L_BIG_ENDIAN
5
+ # else
6
+ # define L_LITTLE_ENDIAN
7
+ # endif
8
+ # else
9
+ # define L_LITTLE_ENDIAN
10
+ # endif
11
+ #endif
@@ -0,0 +1,281 @@
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_ENVIRON_H
17
+ #define LEPTONICA_ENVIRON_H
18
+
19
+ /*------------------------------------------------------------------------*
20
+ * Defines and includes differ for Unix and Windows. Also for Windows, *
21
+ * differentiate between conditionals based on platform and compiler. *
22
+ * For platforms: *
23
+ * _WIN32 => Windows, 32- or 64-bit *
24
+ * _WIN64 => Windows, 64-bit only *
25
+ * __CYGWIN__ => Cygwin *
26
+ * For compilers: *
27
+ * __GNUC__ => gcc *
28
+ * _MSC_VER => msvc *
29
+ *------------------------------------------------------------------------*/
30
+
31
+ /* MS VC++ does not provide stdint.h, so define the missing types here */
32
+
33
+ #ifndef _MSC_VER
34
+ #include <stdint.h>
35
+
36
+ #else
37
+ /* Note that _WIN32 is defined for both 32 and 64 bit applications,
38
+ whereas _WIN64 is defined only for the latter */
39
+
40
+ #ifdef _WIN64
41
+ typedef __int64 intptr_t;
42
+ typedef unsigned __int64 uintptr_t;
43
+ #else
44
+ typedef int intptr_t;
45
+ typedef unsigned int uintptr_t;
46
+ #endif
47
+
48
+ /* VC++6 doesn't seem to have powf, expf. */
49
+ #if (_MSC_VER < 1400)
50
+ #define powf(x, y) (float)pow((double)(x), (double)(y))
51
+ #define expf(x) (float)exp((double)(x))
52
+ #endif
53
+
54
+ #endif /* _MSC_VER */
55
+
56
+ /* Windows specifics */
57
+
58
+ #ifdef _WIN32
59
+
60
+ /* DLL EXPORTS and IMPORTS:
61
+ * Important: LEPTONLIB_* is deprected. It is retained here only for
62
+ * compatibility with tesseract 3.00. In your project files, use
63
+ * LIBLEPT_EXPORTS and LIBLEPT_IMPORTS */
64
+ #if defined(LIBLEPT_EXPORTS) || defined(LEPTONLIB_EXPORTS)
65
+ #define LEPT_DLL __declspec(dllexport)
66
+ #elif defined(LIBLEPT_IMPORTS) || defined(LEPTONLIB_IMPORTS)
67
+ #define LEPT_DLL __declspec(dllimport)
68
+ #else
69
+ #define LEPT_DLL
70
+ #endif
71
+
72
+ #else /* non-WINDOWS-SPECIFICS */
73
+ #include <stdint.h>
74
+ #define LEPT_DLL
75
+ #endif /* _WIN32 */
76
+
77
+ typedef intptr_t l_intptr_t;
78
+ typedef uintptr_t l_uintptr_t;
79
+ typedef void *L_TIMER;
80
+
81
+
82
+ /*--------------------------------------------------------------------*
83
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
84
+ * USER CONFIGURABLE *
85
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
86
+ * Environ variables with I/O libraries *
87
+ * Manual Configuration Only: NOT AUTO_CONF *
88
+ *--------------------------------------------------------------------*/
89
+ /*
90
+ * Leptonica provides interfaces to link to five external image I/O
91
+ * libraries, plus zlib. Setting any of these to 0 here causes
92
+ * non-functioning stubs to be linked.
93
+ */
94
+ #ifndef HAVE_CONFIG_H
95
+ #define HAVE_LIBJPEG 1
96
+ #define HAVE_LIBTIFF 1
97
+ #define HAVE_LIBPNG 1
98
+ #define HAVE_LIBZ 1
99
+ #define HAVE_LIBGIF 0
100
+ #define HAVE_LIBUNGIF 0
101
+ #define HAVE_LIBWEBP 0
102
+ #endif /* ~HAVE_CONFIG_H */
103
+
104
+ /*
105
+ * On linux systems, you can do I/O between Pix and memory. Specifically,
106
+ * you can compress (write compressed data to memory from a Pix) and
107
+ * uncompress (read from compressed data in memory to a Pix).
108
+ * For jpeg, png, pnm and bmp, these use the non-posix GNU functions
109
+ * fmemopen() and open_memstream(). These functions are not
110
+ * available on other systems. To use these functions in linux,
111
+ * you must define HAVE_FMEMOPEN to be 1 here.
112
+ */
113
+ #ifndef HAVE_CONFIG_H
114
+ #define HAVE_FMEMOPEN 0
115
+ #endif /* ~HAVE_CONFIG_H */
116
+
117
+
118
+ /*--------------------------------------------------------------------*
119
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
120
+ * USER CONFIGURABLE *
121
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
122
+ * Environ variables for uncompressed formatted image I/O *
123
+ *--------------------------------------------------------------------*/
124
+ /*
125
+ * Leptonica supplies image I/O for pnm, bmp, ps, and pdf.
126
+ * Setting any of these to 0 causes non-functioning stubs to be linked.
127
+ */
128
+ #define USE_BMPIO 1
129
+ #define USE_PNMIO 1
130
+ #define USE_PSIO 1
131
+ #define USE_PDFIO 1
132
+
133
+
134
+ /*--------------------------------------------------------------------*
135
+ * Built-in types *
136
+ *--------------------------------------------------------------------*/
137
+ typedef signed char l_int8;
138
+ typedef unsigned char l_uint8;
139
+ typedef short l_int16;
140
+ typedef unsigned short l_uint16;
141
+ typedef int l_int32;
142
+ typedef unsigned int l_uint32;
143
+ typedef float l_float32;
144
+ typedef double l_float64;
145
+
146
+
147
+ /*------------------------------------------------------------------------*
148
+ * Standard macros *
149
+ *------------------------------------------------------------------------*/
150
+ #ifndef L_MIN
151
+ #define L_MIN(x,y) (((x) < (y)) ? (x) : (y))
152
+ #endif
153
+
154
+ #ifndef L_MAX
155
+ #define L_MAX(x,y) (((x) > (y)) ? (x) : (y))
156
+ #endif
157
+
158
+ #ifndef L_ABS
159
+ #define L_ABS(x) (((x) < 0) ? (-1 * (x)) : (x))
160
+ #endif
161
+
162
+ #ifndef L_SIGN
163
+ #define L_SIGN(x) (((x) < 0) ? -1 : 1)
164
+ #endif
165
+
166
+ #ifndef UNDEF
167
+ #define UNDEF -1
168
+ #endif
169
+
170
+ #ifndef NULL
171
+ #define NULL 0
172
+ #endif
173
+
174
+ #ifndef TRUE
175
+ #define TRUE 1
176
+ #endif
177
+
178
+ #ifndef FALSE
179
+ #define FALSE 0
180
+ #endif
181
+
182
+
183
+ /*--------------------------------------------------------------------*
184
+ * Environ variables used within compiler invocation *
185
+ *--------------------------------------------------------------------*/
186
+ /*
187
+ * To control conditional compilation, one of two variables
188
+ *
189
+ * L_LITTLE_ENDIAN (e.g., for Intel X86)
190
+ * L_BIG_ENDIAN (e.g., for Sun SPARC, Mac Power PC)
191
+ *
192
+ * is defined when the GCC compiler is invoked.
193
+ * All code should compile properly for both hardware architectures.
194
+ */
195
+
196
+
197
+ /*------------------------------------------------------------------------*
198
+ * Simple search state variables *
199
+ *------------------------------------------------------------------------*/
200
+ enum {
201
+ L_NOT_FOUND = 0,
202
+ L_FOUND = 1
203
+ };
204
+
205
+
206
+ /*------------------------------------------------------------------------*
207
+ * Standard memory allocation *
208
+ *
209
+ * These specify the memory management functions that are used
210
+ * on all heap data except for Pix. Memory management for Pix
211
+ * also defaults to malloc and free. See pix1.c for details.
212
+ *------------------------------------------------------------------------*/
213
+ #define MALLOC(blocksize) malloc(blocksize)
214
+ #define CALLOC(numelem, elemsize) calloc(numelem, elemsize)
215
+ #define REALLOC(ptr, blocksize) realloc(ptr, blocksize)
216
+ #define FREE(ptr) free(ptr)
217
+
218
+
219
+ /*------------------------------------------------------------------------*
220
+ * Control printing of error, warning, and info messages *
221
+ * *
222
+ * (Use -DNO_CONSOLE_IO on compiler line to prevent text output) *
223
+ *------------------------------------------------------------------------*/
224
+ #ifdef NO_CONSOLE_IO
225
+
226
+ #define PROCNAME(name)
227
+ #define ERROR_PTR(a,b,c) ((void *)(c))
228
+ #define ERROR_INT(a,b,c) ((l_int32)(c))
229
+ #define ERROR_FLOAT(a,b,c) ((l_float32)(c))
230
+ #define L_ERROR(a,b)
231
+ #define L_ERROR_STRING(a,b,c)
232
+ #define L_ERROR_INT(a,b,c)
233
+ #define L_ERROR_FLOAT(a,b,c)
234
+ #define L_WARNING(a,b)
235
+ #define L_WARNING_STRING(a,b,c)
236
+ #define L_WARNING_INT(a,b,c)
237
+ #define L_WARNING_INT2(a,b,c,d)
238
+ #define L_WARNING_FLOAT(a,b,c)
239
+ #define L_WARNING_FLOAT2(a,b,c,d)
240
+ #define L_INFO(a,b)
241
+ #define L_INFO_STRING(a,b,c)
242
+ #define L_INFO_INT(a,b,c)
243
+ #define L_INFO_INT2(a,b,c,d)
244
+ #define L_INFO_FLOAT(a,b,c)
245
+ #define L_INFO_FLOAT2(a,b,c,d)
246
+
247
+ #else
248
+
249
+ #define PROCNAME(name) static const char procName[] = name
250
+ #define ERROR_PTR(a,b,c) returnErrorPtr((a),(b),(c))
251
+ #define ERROR_INT(a,b,c) returnErrorInt((a),(b),(c))
252
+ #define ERROR_FLOAT(a,b,c) returnErrorFloat((a),(b),(c))
253
+ #define L_ERROR(a,b) l_error((a),(b))
254
+ #define L_ERROR_STRING(a,b,c) l_errorString((a),(b),(c))
255
+ #define L_ERROR_INT(a,b,c) l_errorInt((a),(b),(c))
256
+ #define L_ERROR_FLOAT(a,b,c) l_errorFloat((a),(b),(c))
257
+ #define L_WARNING(a,b) l_warning((a),(b))
258
+ #define L_WARNING_STRING(a,b,c) l_warningString((a),(b),(c))
259
+ #define L_WARNING_INT(a,b,c) l_warningInt((a),(b),(c))
260
+ #define L_WARNING_INT2(a,b,c,d) l_warningInt2((a),(b),(c),(d))
261
+ #define L_WARNING_FLOAT(a,b,c) l_warningFloat((a),(b),(c))
262
+ #define L_WARNING_FLOAT2(a,b,c,d) l_warningFloat2((a),(b),(c),(d))
263
+ #define L_INFO(a,b) l_info((a),(b))
264
+ #define L_INFO_STRING(a,b,c) l_infoString((a),(b),(c))
265
+ #define L_INFO_INT(a,b,c) l_infoInt((a),(b),(c))
266
+ #define L_INFO_INT2(a,b,c,d) l_infoInt2((a),(b),(c),(d))
267
+ #define L_INFO_FLOAT(a,b,c) l_infoFloat((a),(b),(c))
268
+ #define L_INFO_FLOAT2(a,b,c,d) l_infoFloat2((a),(b),(c),(d))
269
+
270
+ #endif /* NO_CONSOLE_IO */
271
+
272
+
273
+ /*------------------------------------------------------------------------*
274
+ * snprintf() renamed in MSVC *
275
+ *------------------------------------------------------------------------*/
276
+ #ifdef _MSC_VER
277
+ #define snprintf(buf, size, ...) _snprintf_s(buf, size, _TRUNCATE, __VA_ARGS__)
278
+ #endif
279
+
280
+
281
+ #endif /* LEPTONICA_ENVIRON_H */