00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef TESSERACT_TRAINING_COMMONTRAINING_H__
00015 #define TESSERACT_TRAINING_COMMONTRAINING_H__
00016
00017 #include "oldlist.h"
00018 #include "cluster.h"
00019 #include "intproto.h"
00020
00021
00023
00025 #define MAXNAMESIZE 80
00026 #define MINSD_ANGLE (1.0f / 64.0f)
00027
00028
00030
00032 extern BOOL8 ShowSignificantProtos;
00033 extern BOOL8 ShowInsignificantProtos;
00034 extern BOOL8 ShowAllSamples;
00035
00036
00037 extern CLUSTERCONFIG Config;
00038 extern FLOAT32 RoundingAccuracy;
00039
00040 extern char CTFontName[MAXNAMESIZE];
00041
00042 extern char *Directory;
00043
00044 extern const char* test_ch;
00045
00046 extern const char *InputUnicharsetFile;
00047 extern const char *OutputUnicharsetFile;
00048
00049 extern const char *InputFontInfoFile;
00050
00051
00052 extern UNICHARSET unicharset_training;
00053
00055
00057 typedef struct
00058 {
00059 char *Label;
00060 int SampleCount;
00061 LIST List;
00062 }
00063 LABELEDLISTNODE, *LABELEDLIST;
00064
00065 typedef struct
00066 {
00067 char* Label;
00068 int NumMerged[MAX_NUM_PROTOS];
00069 CLASS_TYPE Class;
00070 }MERGE_CLASS_NODE;
00071 typedef MERGE_CLASS_NODE* MERGE_CLASS;
00072
00073
00075
00077 void ParseArguments(
00078 int argc,
00079 char **argv);
00080
00081 char *GetNextFilename(int Argc, char** argv);
00082
00083 LABELEDLIST FindList(
00084 LIST List,
00085 char *Label);
00086
00087 LABELEDLIST NewLabeledList(
00088 const char *Label);
00089
00090 void WriteTrainingSamples(
00091 char *Directory,
00092 LIST CharList,
00093 const char *program_feature_type);
00094
00095 void FreeTrainingSamples(
00096 LIST CharList);
00097
00098 void FreeLabeledList(
00099 LABELEDLIST LabeledList);
00100
00101 void FreeLabeledClassList(
00102 LIST ClassListList);
00103
00104 CLUSTERER *SetUpForClustering(
00105 LABELEDLIST CharSample,
00106 const char *program_feature_type);
00107
00108 LIST RemoveInsignificantProtos(
00109 LIST ProtoList,
00110 BOOL8 KeepSigProtos,
00111 BOOL8 KeepInsigProtos,
00112 int N);
00113
00114 void CleanUpUnusedData(
00115 LIST ProtoList);
00116
00117 void MergeInsignificantProtos(
00118 LIST ProtoList,
00119 const char *label,
00120 CLUSTERER *Clusterer,
00121 CLUSTERCONFIG *Config);
00122
00123 MERGE_CLASS FindClass(
00124 LIST List,
00125 char *Label);
00126
00127 MERGE_CLASS NewLabeledClass(
00128 char *Label);
00129
00130 void FreeTrainingSamples(
00131 LIST CharList);
00132
00133 void SetUpForFloat2Int(
00134 LIST LabeledClassList);
00135
00136 void Normalize(
00137 float *Values);
00138
00139 void FreeNormProtoList(
00140 LIST CharList);
00141
00142 void AddToNormProtosList(
00143 LIST* NormProtoList,
00144 LIST ProtoList,
00145 char *CharName);
00146
00147 int NumberOfProtos(
00148 LIST ProtoList,
00149 BOOL8 CountSigProtos,
00150 BOOL8 CountInsigProtos);
00151
00152
00153 void allocNormProtos();
00154 #endif // TESSERACT_TRAINING_COMMONTRAINING_H__