File: protos.h

package info (click to toggle)
tesseract 2.04-2%2Bsqueeze1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 7,336 kB
  • ctags: 6,860
  • sloc: cpp: 81,388; sh: 3,446; java: 1,220; makefile: 376
file content (258 lines) | stat: -rw-r--r-- 6,903 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/* -*-C-*-
 ********************************************************************************
 *
 * File:        protos.h  (Formerly protos.h)
 * Description:
 * Author:       Mark Seaman, SW Productivity
 * Created:      Fri Oct 16 14:37:00 1987
 * Modified:     Fri Jul 12 10:06:55 1991 (Dan Johnson) danj@hpgrlj
 * Language:     C
 * Package:      N/A
 * Status:       Reusable Software Component
 *
 * (c) Copyright 1987, Hewlett-Packard Company.
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 ** http://www.apache.org/licenses/LICENSE-2.0
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.
 *
 *********************************************************************************/
#ifndef PROTOS_H
#define PROTOS_H

/*----------------------------------------------------------------------
              I n c l u d e s
----------------------------------------------------------------------*/
#include "bitvec.h"
#include "cutil.h"
#include "unichar.h"

/*----------------------------------------------------------------------
              T y p e s
----------------------------------------------------------------------*/
typedef BIT_VECTOR *CONFIGS;

typedef struct
{
  FLOAT32 A;
  FLOAT32 B;
  FLOAT32 C;
  FLOAT32 X;
  FLOAT32 Y;
  FLOAT32 Angle;
  FLOAT32 Length;
} PROTO_STRUCT;
typedef PROTO_STRUCT *PROTO;

typedef struct
{
  inT16 NumProtos;
  inT16 MaxNumProtos;
  PROTO Prototypes;
  inT16 NumConfigs;
  inT16 MaxNumConfigs;
  CONFIGS Configurations;
} CLASS_STRUCT;
typedef CLASS_STRUCT *CLASS_TYPE;
typedef CLASS_STRUCT *CLASSES;

/*----------------------------------------------------------------------
              C o n s t a n t s
----------------------------------------------------------------------*/
#define NUMBER_OF_CLASSES  MAX_NUM_CLASSES
#define Y_OFFSET           -40.0
#define FEATURE_SCALE      100.0

/*----------------------------------------------------------------------
              V a r i a b l e s
----------------------------------------------------------------------*/
extern CLASS_STRUCT TrainingData[];

/*----------------------------------------------------------------------
              M a c r o s
----------------------------------------------------------------------*/
/**********************************************************************
 * AddProtoToConfig
 *
 * Set a single proto bit in the specified configuration.
 **********************************************************************/

#define AddProtoToConfig(Pid,Config)	\
(SET_BIT (Config, Pid))

/**********************************************************************
 * RemoveProtoFromConfig
 *
 * Clear a single proto bit in the specified configuration.
 **********************************************************************/

#define RemoveProtoFromConfig(Pid,Config)	\
(reset_bit (Config, Pid))

/**********************************************************************
 * ClassOfChar
 *
 * Return the class of a particular ASCII character value.
 **********************************************************************/

#define ClassOfChar(Char)            \
((TrainingData [Char].NumProtos) ? \
	(& TrainingData [Char])         : \
	NO_CLASS)

/**********************************************************************
 * ProtoIn
 *
 * Choose the selected prototype in this class record.  Return the
 * pointer to it (type PROTO).
 **********************************************************************/

#define ProtoIn(Class,Pid)  \
(& (Class)->Prototypes [Pid])

/**********************************************************************
 * PrintProto
 *
 * Print out the contents of a prototype.   The 'Proto' argument is of
 * type 'PROTO'.
 **********************************************************************/

#define PrintProto(Proto)                      \
(cprintf ("X=%4.2f, Y=%4.2f, Angle=%4.2f",    \
			Proto->X,                \
			Proto->Y,                \
			Proto->Length,                \
			Proto->Angle))                \


/**********************************************************************
 * PrintProtoLine
 *
 * Print out the contents of a prototype.   The 'Proto' argument is of
 * type 'PROTO'.
 **********************************************************************/

#define PrintProtoLine(Proto)             \
(cprintf ("A=%4.2f, B=%4.2f, C=%4.2f",   \
			Proto->A,           \
			Proto->B,           \
			Proto->C))           \

/*----------------------------------------------------------------------
              F u n c t i o n s
----------------------------------------------------------------------*/
int AddConfigToClass(CLASS_TYPE Class);

int AddProtoToClass(CLASS_TYPE Class);

FLOAT32 ClassConfigLength(CLASS_TYPE Class, BIT_VECTOR Config);

FLOAT32 ClassProtoLength(CLASS_TYPE Class);

void CopyProto(PROTO Src, PROTO Dest);

void FillABC(PROTO Proto);

void FreeClass(CLASS_TYPE Class);

void FreeClassFields(CLASS_TYPE Class);

void InitPrototypes();

CLASS_TYPE NewClass(int NumProtos, int NumConfigs);

void PrintProtos(CLASS_TYPE Class);

void ReadClassFile();

void ReadClassFromFile(FILE *File, UNICHAR_ID unichar_id);

void ReadConfigs(register FILE *File, CLASS_TYPE Class);

void ReadProtos(register FILE *File, CLASS_TYPE Class);

int SplitProto(CLASS_TYPE Class, int OldPid);

void WriteOldConfigFile(FILE *File, CLASS_TYPE Class);

void WriteOldProtoFile(FILE *File, CLASS_TYPE Class);

/*
#if defined(__STDC__) || defined(__cplusplus)
# define _ARGS(s) s
#else
# define _ARGS(s) ()
#endif*/

/* protos.c *
int AddConfigToClass
  _ARGS((CLASS_TYPE Class));

int AddProtoToClass
  _ARGS((CLASS_TYPE Class));

FLOAT32 ClassConfigLength
  _ARGS((CLASS_TYPE Class,
  BIT_VECTOR Config));

FLOAT32 ClassProtoLength
  _ARGS((CLASS_TYPE Class));

void CopyProto
  _ARGS((PROTO Src,
  PROTO Dest));

void FillABC
  _ARGS((PROTO Proto));

void FreeClass
  _ARGS((CLASS_TYPE Class));

void FreeClassFields
  _ARGS((CLASS_TYPE Class));

void InitPrototypes
  _ARGS((void));

CLASS_TYPE NewClass
  _ARGS((int NumProtos,
  int NumConfigs));

void PrintProtos
  _ARGS((CLASS_TYPE Class));

void ReadClassFile
  _ARGS((void));

void ReadClassFromFile
  _ARGS((FILE *File,
  int ClassChar));

void ReadConfigs
  _ARGS((FILE *File,
  CLASS_TYPE Class));

void ReadProtos
  _ARGS((FILE *File,
  CLASS_TYPE Class));

int SplitProto
  _ARGS((CLASS_TYPE Class,
  int OldPid));

void WriteOldConfigFile
  _ARGS((FILE *File,
  CLASS_TYPE Class));

void WriteOldProtoFile
  _ARGS((FILE *File,
  CLASS_TYPE Class));

#undef _ARGS
*/
#endif