|
1 #ifndef _SYSTEM_H |
|
2 #define _SYSTEM_H |
|
3 #include <stdio.h> |
|
4 #include <stdlib.h> |
|
5 #include "/usr/sww/share/include/tiffio.h" |
|
6 #include <assert.h> |
|
7 #include <bool.h> |
|
8 #include <iostream.h> |
|
9 #include <stream.h> |
|
10 #include <stdlib.h> |
|
11 |
|
12 /* system.h - typedefs and globals for OCRchie system **/ |
|
13 /** enums and typdefs for OCRSystem include .h files */ |
|
14 |
|
15 |
|
16 enum MapStatus { EMPTY, VALID, OPENERROR, READERROR, WRITEERROR, |
|
17 OTHERERROR }; |
|
18 |
|
19 enum TclMode {REGULAR, ZONING}; |
|
20 |
|
21 typedef double Angle; |
|
22 typedef unsigned char uchar; |
|
23 typedef unsigned int Confidence; |
|
24 |
|
25 typedef unsigned long int Distance; |
|
26 |
|
27 typedef short int Property; |
|
28 typedef char Character; |
|
29 |
|
30 |
|
31 /** The number of properties in the property vector for components */ |
|
32 extern int numProperties; |
|
33 |
|
34 /** Some variables for fine tuning OCR */ |
|
35 /** These variables can be changed without recompiling in link_vars.tcl */ |
|
36 |
|
37 extern int NoiseTolerance; // Minimum number of pixels in row of text |
|
38 extern int MinLineSize; // Minimum number of rows in a line of text |
|
39 extern int MinVertSeparation; // Minimum number of rows between lines of tex |
|
40 extern int MinHorizSeparation; // Minimum number of blank pixels btween chars |
|
41 extern int ConfidenceThreshold;// Minimum confidence for some operations |
|
42 extern int JoinTolerance; // Maximum number of pixels in a column |
|
43 // joining two fused characters |
|
44 extern int MinComponentSize; //Minimum size in pixels of smallest char |
|
45 |
|
46 // The next four are used in character grouping |
|
47 |
|
48 extern int MaxVertSize; // Max vert pixels in char (used for baseline) |
|
49 extern int BaseLineTolerance; // How far from baseline is okay 1/%linesize |
|
50 extern int TopLineTolerance; // How far from topline is okay 1/%linesize |
|
51 |
|
52 |
|
53 /** Variables for user interface can be set in the file link_vars.tcl **/ |
|
54 |
|
55 extern int ENABLE_USER_INTERFACE; |
|
56 extern int VERY_LOW_CONFIDENCE; |
|
57 extern int LOW_CONFIDENCE; |
|
58 extern int DISPLAY_LINE_BOUNDARIES; |
|
59 extern int DISPLAY_BOUNDING_BOXES; |
|
60 extern int SPELLCHECK; |
|
61 extern int DISPLAY_IMAGE; |
|
62 #define RLE_DESKEW 1 |
|
63 #define BITMAP_DESKEW 0; |
|
64 #define MINIMUM_SKEW_ANGLE 0.25 |
|
65 extern int DESKEW_METHOD; |
|
66 extern double SCALE_FACTOR; |
|
67 extern double ZONING_SCALE_FACTOR; |
|
68 extern TclMode mode; |
|
69 |
|
70 /***** end link_vars.tcl section ****/ |
|
71 #include "Point.h" |
|
72 #include "list.h" |
|
73 #include "BitMap.h" |
|
74 #include "Component.h" |
|
75 #include "Word.h" |
|
76 #include "learn.h" |
|
77 #include "RLEPair.h" |
|
78 #include "RLEMap.h" |
|
79 #include "EqnMarker.h" |
|
80 #include "Zone.h" |
|
81 |
|
82 |
|
83 // Define C++ mode for tiff library |
|
84 #ifndef __cplusplus |
|
85 #define __cplusplus |
|
86 #endif |
|
87 |
|
88 |
|
89 |
|
90 extern Point NOPNT; // Just a convenient empty point. |
|
91 |
|
92 |
|
93 /* Constants for the number of horizontal and vertical divisions |
|
94 for determining the gray scale property vector for each component */ |
|
95 |
|
96 extern int NumHorizDiv; //Number of horizontal divisions |
|
97 extern int NumVertDiv; //Number of vertical divisions |
|
98 |
|
99 extern Component * LearnedChars; /** Averaged learned chars NOT USED */ |
|
100 |
|
101 extern unsigned int NumCharGroups; |
|
102 extern Components * LearnedGroups; // An array of 5 learned characters |
|
103 //group lists |
|
104 |
|
105 /** The next 3 are set during learning ***/ |
|
106 extern double MaxHWRatio; // Max H/W ratio of learned set |
|
107 extern double MinHWRatio; |
|
108 extern int MinWidth; // minimum component width in learned set |
|
109 |
|
110 extern uchar CharBitsSet[]; //a table of the number of bits set // in a character |
|
111 // initialized in initCharBitsSet() |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 // *** Global function declaration *** |
|
119 // functions in RLEMap.cc |
|
120 |
|
121 void testocr(int argc, char **argv); |
|
122 void testRLEMap(char * filename); // Right now in RLEMap.cc |
|
123 void testBitMap(char * filename); // Right now in BitMap.cc |
|
124 void testpixelsBetween(RLEMap * map); // in RLEMap.cc tests center row |
|
125 void printMap(RLEMap * map); // just an ascii "X" display |
|
126 |
|
127 |
|
128 // functions in BitMap.cc |
|
129 void testPixelsInRegion(BitMap * bmap, RLEMap * rmap); |
|
130 |
|
131 // functions in convertMap.cc |
|
132 void testConvertMap(char * filename); |
|
133 |
|
134 // functions in Component.cc |
|
135 void printVector(short int vector[], int size); // just prints contents |
|
136 |
|
137 // prints properties of component c using grayscales from map. |
|
138 void testProperties(Component* c, BitMap * map); |
|
139 |
|
140 |
|
141 // functions in learn.cc |
|
142 Components * readLearnedChars(char * tiffFile, char * transFile); |
|
143 /** Read Learned characters uses a tiffFile and a |
|
144 ASCII translation file to read in a component list for |
|
145 for comparison ***/ |
|
146 |
|
147 // in system.cc |
|
148 void initCharBitsSet(); |
|
149 void invertBitsInBuffer(uchar * buf, int size); |
|
150 void clearBitsInBuffer(uchar * buf, int size); |
|
151 |
|
152 short int countBitsSet(uchar c); |
|
153 int pixelsBetween(uchar * ar, int start, int end); |
|
154 void setRange(uchar ar[], int start, int end); |
|
155 char* backslashify(char*); |
|
156 |
|
157 #endif |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |