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