Tesseract 3.01
|
00001 /* -*-C-*- 00002 ******************************************************************************** 00003 * 00004 * File: protos.h (Formerly protos.h) 00005 * Description: 00006 * Author: Mark Seaman, SW Productivity 00007 * Created: Fri Oct 16 14:37:00 1987 00008 * Modified: Fri Jul 12 10:06:55 1991 (Dan Johnson) danj@hpgrlj 00009 * Language: C 00010 * Package: N/A 00011 * Status: Reusable Software Component 00012 * 00013 * (c) Copyright 1987, Hewlett-Packard Company. 00014 ** Licensed under the Apache License, Version 2.0 (the "License"); 00015 ** you may not use this file except in compliance with the License. 00016 ** You may obtain a copy of the License at 00017 ** http://www.apache.org/licenses/LICENSE-2.0 00018 ** Unless required by applicable law or agreed to in writing, software 00019 ** distributed under the License is distributed on an "AS IS" BASIS, 00020 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00021 ** See the License for the specific language governing permissions and 00022 ** limitations under the License. 00023 * 00024 *********************************************************************************/ 00025 #ifndef PROTOS_H 00026 #define PROTOS_H 00027 00028 /*---------------------------------------------------------------------- 00029 I n c l u d e s 00030 ----------------------------------------------------------------------*/ 00031 #include "bitvec.h" 00032 #include "cutil.h" 00033 #include "unichar.h" 00034 #include "unicity_table.h" 00035 #include "params.h" 00036 00037 /*---------------------------------------------------------------------- 00038 T y p e s 00039 ----------------------------------------------------------------------*/ 00040 typedef BIT_VECTOR *CONFIGS; 00041 00042 typedef struct 00043 { 00044 FLOAT32 A; 00045 FLOAT32 B; 00046 FLOAT32 C; 00047 FLOAT32 X; 00048 FLOAT32 Y; 00049 FLOAT32 Angle; 00050 FLOAT32 Length; 00051 } PROTO_STRUCT; 00052 typedef PROTO_STRUCT *PROTO; 00053 00054 typedef struct 00055 { 00056 inT16 NumProtos; 00057 inT16 MaxNumProtos; 00058 PROTO Prototypes; 00059 inT16 NumConfigs; 00060 inT16 MaxNumConfigs; 00061 CONFIGS Configurations; 00062 UnicityTableEqEq<int> font_set; 00063 } CLASS_STRUCT; 00064 typedef CLASS_STRUCT *CLASS_TYPE; 00065 typedef CLASS_STRUCT *CLASSES; 00066 00067 /*---------------------------------------------------------------------- 00068 C o n s t a n t s 00069 ----------------------------------------------------------------------*/ 00070 #define NUMBER_OF_CLASSES MAX_NUM_CLASSES 00071 #define Y_OFFSET -40.0 00072 #define FEATURE_SCALE 100.0 00073 00074 /*---------------------------------------------------------------------- 00075 V a r i a b l e s 00076 ----------------------------------------------------------------------*/ 00077 extern CLASS_STRUCT TrainingData[]; 00078 00079 extern STRING_VAR_H(classify_training_file, "MicroFeatures", "Training file"); 00080 00081 /*---------------------------------------------------------------------- 00082 M a c r o s 00083 ----------------------------------------------------------------------*/ 00090 #define AddProtoToConfig(Pid,Config) \ 00091 (SET_BIT (Config, Pid)) 00092 00099 #define RemoveProtoFromConfig(Pid,Config) \ 00100 (reset_bit (Config, Pid)) 00101 00108 #define ClassOfChar(Char) \ 00109 ((TrainingData [Char].NumProtos) ? \ 00110 (& TrainingData [Char]) : \ 00111 NO_CLASS) 00112 00120 #define ProtoIn(Class,Pid) \ 00121 (& (Class)->Prototypes [Pid]) 00122 00130 #define PrintProto(Proto) \ 00131 (cprintf ("X=%4.2f, Y=%4.2f, Angle=%4.2f", \ 00132 Proto->X, \ 00133 Proto->Y, \ 00134 Proto->Length, \ 00135 Proto->Angle)) \ 00136 00137 00145 #define PrintProtoLine(Proto) \ 00146 (cprintf ("A=%4.2f, B=%4.2f, C=%4.2f", \ 00147 Proto->A, \ 00148 Proto->B, \ 00149 Proto->C)) \ 00150 00151 /*---------------------------------------------------------------------- 00152 F u n c t i o n s 00153 ----------------------------------------------------------------------*/ 00154 int AddConfigToClass(CLASS_TYPE Class); 00155 00156 int AddProtoToClass(CLASS_TYPE Class); 00157 00158 FLOAT32 ClassConfigLength(CLASS_TYPE Class, BIT_VECTOR Config); 00159 00160 FLOAT32 ClassProtoLength(CLASS_TYPE Class); 00161 00162 void CopyProto(PROTO Src, PROTO Dest); 00163 00164 void FillABC(PROTO Proto); 00165 00166 void FreeClass(CLASS_TYPE Class); 00167 00168 void FreeClassFields(CLASS_TYPE Class); 00169 00170 void InitPrototypes(); 00171 00172 CLASS_TYPE NewClass(int NumProtos, int NumConfigs); 00173 00174 void PrintProtos(CLASS_TYPE Class); 00175 00176 void ReadClassFromFile(FILE *File, UNICHAR_ID unichar_id); 00177 00178 void ReadConfigs(register FILE *File, CLASS_TYPE Class); 00179 00180 void ReadProtos(register FILE *File, CLASS_TYPE Class); 00181 00182 int SplitProto(CLASS_TYPE Class, int OldPid); 00183 00184 void WriteOldConfigFile(FILE *File, CLASS_TYPE Class); 00185 00186 void WriteOldProtoFile(FILE *File, CLASS_TYPE Class); 00187 00188 #endif