Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
protos.h
Go to the documentation of this file.
1 /* -*-C-*-
2 ********************************************************************************
3 *
4 * File: protos.h (Formerly protos.h)
5 * Description:
6 * Author: Mark Seaman, SW Productivity
7 * Created: Fri Oct 16 14:37:00 1987
8 * Modified: Fri Jul 12 10:06:55 1991 (Dan Johnson) danj@hpgrlj
9 * Language: C
10 * Package: N/A
11 * Status: Reusable Software Component
12 *
13 * (c) Copyright 1987, Hewlett-Packard Company.
14 ** Licensed under the Apache License, Version 2.0 (the "License");
15 ** you may not use this file except in compliance with the License.
16 ** You may obtain a copy of the License at
17 ** http://www.apache.org/licenses/LICENSE-2.0
18 ** Unless required by applicable law or agreed to in writing, software
19 ** distributed under the License is distributed on an "AS IS" BASIS,
20 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 ** See the License for the specific language governing permissions and
22 ** limitations under the License.
23 *
24 *********************************************************************************/
25 #ifndef PROTOS_H
26 #define PROTOS_H
27
28 /*----------------------------------------------------------------------
29 I n c l u d e s
30 ----------------------------------------------------------------------*/
31 #include "bitvec.h"
32 #include "cutil.h"
33 #include "unichar.h"
34 #include "unicity_table.h"
35 #include "params.h"
36
37 /*----------------------------------------------------------------------
38 T y p e s
39 ----------------------------------------------------------------------*/
40 typedef BIT_VECTOR *CONFIGS;
41
42 typedef struct
43 {
44 FLOAT32 A;
45 FLOAT32 B;
46 FLOAT32 C;
47 FLOAT32 X;
48 FLOAT32 Y;
49 FLOAT32 Angle;
50 FLOAT32 Length;
51 } PROTO_STRUCT;
52 typedef PROTO_STRUCT *PROTO;
53
54 struct CLASS_STRUCT {
55 CLASS_STRUCT()
56 : NumProtos(0), MaxNumProtos(0), Prototypes(NULL),
57 NumConfigs(0), MaxNumConfigs(0), Configurations(NULL) {
58 }
59 inT16 NumProtos;
60 inT16 MaxNumProtos;
61 PROTO Prototypes;
62 inT16 NumConfigs;
63 inT16 MaxNumConfigs;
64 CONFIGS Configurations;
65 UnicityTableEqEq<int> font_set;
66 };
67 typedef CLASS_STRUCT *CLASS_TYPE;
68 typedef CLASS_STRUCT *CLASSES;
69
70 /*----------------------------------------------------------------------
71 C o n s t a n t s
72 ----------------------------------------------------------------------*/
73 #define NUMBER_OF_CLASSES MAX_NUM_CLASSES
74 #define Y_OFFSET -40.0
75 #define FEATURE_SCALE 100.0
76
77 /*----------------------------------------------------------------------
78 V a r i a b l e s
79 ----------------------------------------------------------------------*/
80 extern CLASS_STRUCT TrainingData[];
81
82 extern STRING_VAR_H(classify_training_file, "MicroFeatures", "Training file");
83
84 /*----------------------------------------------------------------------
85 M a c r o s
86 ----------------------------------------------------------------------*/
93 #define AddProtoToConfig(Pid,Config) \
94 (SET_BIT (Config, Pid))
95
102 #define RemoveProtoFromConfig(Pid,Config) \
103 (reset_bit (Config, Pid))
104
111 #define ClassOfChar(Char) \
112 ((TrainingData [Char].NumProtos) ? \
113 (& TrainingData [Char]) : \
114 NO_CLASS)
115
123 #define ProtoIn(Class,Pid) \
124 (& (Class)->Prototypes [Pid])
125
133 #define PrintProto(Proto) \
134 (cprintf ("X=%4.2f, Y=%4.2f, Angle=%4.2f", \
135 Proto->X, \
136 Proto->Y, \
137 Proto->Length, \
138 Proto->Angle)) \
139
140
148 #define PrintProtoLine(Proto) \
149 (cprintf ("A=%4.2f, B=%4.2f, C=%4.2f", \
150 Proto->A, \
151 Proto->B, \
152 Proto->C)) \
153
154 /*----------------------------------------------------------------------
155 F u n c t i o n s
156 ----------------------------------------------------------------------*/
157 int AddConfigToClass(CLASS_TYPE Class);
158
159 int AddProtoToClass(CLASS_TYPE Class);
160
161 FLOAT32 ClassConfigLength(CLASS_TYPE Class, BIT_VECTOR Config);
162
163 FLOAT32 ClassProtoLength(CLASS_TYPE Class);
164
165 void CopyProto(PROTO Src, PROTO Dest);
166
167 void FillABC(PROTO Proto);
168
169 void FreeClass(CLASS_TYPE Class);
170
171 void FreeClassFields(CLASS_TYPE Class);
172
173 void InitPrototypes();
174
175 CLASS_TYPE NewClass(int NumProtos, int NumConfigs);
176
177 void PrintProtos(CLASS_TYPE Class);
178
179 void ReadClassFromFile(FILE *File, UNICHAR_ID unichar_id);
180
181 void ReadConfigs(register FILE *File, CLASS_TYPE Class);
182
183 void ReadProtos(register FILE *File, CLASS_TYPE Class);
184
185 int SplitProto(CLASS_TYPE Class, int OldPid);
186
187 void WriteOldConfigFile(FILE *File, CLASS_TYPE Class);
188
189 void WriteOldProtoFile(FILE *File, CLASS_TYPE Class);
190
191 #endif