tesseract  4.00.00dev
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 ----------------------------------------------------------------------*/
41 
42 typedef struct
43 {
51 } PROTO_STRUCT;
53 
54 struct CLASS_STRUCT {
56  : NumProtos(0), MaxNumProtos(0), Prototypes(NULL),
58  }
66 };
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 (tprintf("X=%4.2f, Y=%4.2f, Length=%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 
162 
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 
176 
177 void PrintProtos(CLASS_TYPE Class);
178 
179 #endif
CLASS_TYPE NewClass(int NumProtos, int NumConfigs)
Definition: protos.cpp:247
CLASS_STRUCT * CLASSES
Definition: protos.h:68
char * classify_training_file
Definition: protos.cpp:49
void FreeClass(CLASS_TYPE Class)
Definition: protos.cpp:214
FLOAT32 A
Definition: protos.h:44
BIT_VECTOR * CONFIGS
Definition: protos.h:40
inT16 MaxNumConfigs
Definition: protos.h:63
inT16 NumConfigs
Definition: protos.h:62
void PrintProtos(CLASS_TYPE Class)
Definition: protos.cpp:272
inT16 NumProtos
Definition: protos.h:59
void FreeClassFields(CLASS_TYPE Class)
Definition: protos.cpp:227
uinT32 * BIT_VECTOR
Definition: bitvec.h:28
FLOAT32 ClassProtoLength(CLASS_TYPE Class)
Definition: protos.cpp:162
CLUSTERCONFIG Config
CONFIGS Configurations
Definition: protos.h:64
int16_t inT16
Definition: host.h:36
CLASS_STRUCT TrainingData[]
Definition: protos.cpp:47
FLOAT32 Length
Definition: protos.h:50
PROTO_STRUCT * PROTO
Definition: protos.h:52
void FillABC(PROTO Proto)
Definition: protos.cpp:197
int AddProtoToClass(CLASS_TYPE Class)
Definition: protos.cpp:98
PROTO Prototypes
Definition: protos.h:61
FLOAT32 Y
Definition: protos.h:48
FLOAT32 X
Definition: protos.h:47
float FLOAT32
Definition: host.h:42
FLOAT32 Angle
Definition: protos.h:49
void InitPrototypes()
#define STRING_VAR_H(name, val, comment)
Definition: params.h:270
UnicityTableEqEq< int > font_set
Definition: protos.h:65
FLOAT32 C
Definition: protos.h:46
int AddConfigToClass(CLASS_TYPE Class)
Definition: protos.cpp:62
FLOAT32 B
Definition: protos.h:45
FLOAT32 ClassConfigLength(CLASS_TYPE Class, BIT_VECTOR Config)
Definition: protos.cpp:141
inT16 MaxNumProtos
Definition: protos.h:60
void CopyProto(PROTO Src, PROTO Dest)
Definition: protos.cpp:181
CLASS_STRUCT * CLASS_TYPE
Definition: protos.h:67
CLASS_STRUCT()
Definition: protos.h:55