tesseract
5.0.0-alpha-619-ge9db
|
Go to the documentation of this file.
34 #define PROGRAM_FEATURE_TYPE "cn"
40 static void WriteNormProtos(
const char *Directory,
LIST LabeledProtoList,
43 static void WriteProtos(FILE* File, uint16_t N,
LIST ProtoList,
44 bool WriteSigProtos,
bool WriteInsigProtos);
104 int main(
int argc,
char *argv[]) {
105 tesseract::CheckSharedLibraryVersion();
110 const char *PageName;
123 printf(
"Reading %s ...\n", PageName);
124 FILE *TrainingPage = fopen(PageName,
"rb");
128 TrainingPage, &CharList);
129 fclose(TrainingPage);
133 printf(
"Clustering ...\n");
137 pCharList = CharList;
146 if (Clusterer ==
nullptr) {
147 fprintf(stderr,
"Error: nullptr clusterer!\n");
161 printf(
"0 significant protos for %s."
162 " Retrying clustering with MinSamples = %f%%\n",
173 WriteNormProtos(FLAGS_D.c_str(), NormProtoList,
176 for (
int i = 0; i < freeable_protos.
size(); ++i) {
196 static void WriteNormProtos(
const char *Directory,
LIST LabeledProtoList,
204 if (Directory !=
nullptr && Directory[0] !=
'\0') {
205 Filename += Directory;
208 Filename +=
"normproto";
209 printf (
"\nWriting %s ...", Filename.
c_str());
210 File = fopen(Filename.
c_str(),
"wb");
212 fprintf(File,
"%0d\n", feature_desc->
NumParams);
219 printf (
"\nError! Not enough protos for %s: %d protos"
220 " (%d significant protos"
221 ", %d insignificant protos)\n",
222 LabeledProto->
Label, N,
227 fprintf(File,
"\n%s %d\n", LabeledProto->
Label, N);
228 WriteProtos(File, feature_desc->
NumParams, LabeledProto->
List,
true,
false);
236 static void WriteProtos(FILE* File, uint16_t N,
LIST ProtoList,
237 bool WriteSigProtos,
bool WriteInsigProtos)
void ReadTrainingSamples(const FEATURE_DEFS_STRUCT &feature_definitions, const char *feature_name, int max_samples, UNICHARSET *unicharset, FILE *file, LIST *training_samples)
void InitFeatureDefs(FEATURE_DEFS_STRUCT *featuredefs)
int NumberOfProtos(LIST ProtoList, bool CountSigProtos, bool CountInsigProtos)
void FreeClusterer(CLUSTERER *Clusterer)
uint32_t ShortNameToFeatureType(const FEATURE_DEFS_STRUCT &FeatureDefs, const char *ShortName)
void FreeProtoList(LIST *ProtoList)
int main(int argc, char *argv[])
const FEATURE_DESC_STRUCT * FeatureDesc[NUM_FEATURE_TYPES]
LIST ClusterSamples(CLUSTERER *Clusterer, CLUSTERCONFIG *Config)
const char * c_str() const
void WriteParamDesc(FILE *File, uint16_t N, const PARAM_DESC ParamDesc[])
const char * GetNextFilename(int argc, const char *const *argv)
#define PROGRAM_FEATURE_TYPE
const PARAM_DESC * ParamDesc
void FreeTrainingSamples(LIST CharList)
void WritePrototype(FILE *File, uint16_t N, PROTOTYPE *Proto)
CLUSTERER * SetUpForClustering(const FEATURE_DEFS_STRUCT &FeatureDefs, LABELEDLIST char_sample, const char *program_feature_type)
void ParseArguments(int *argc, char ***argv)
void AddToNormProtosList(LIST *NormProtoList, LIST ProtoList, char *CharName)
void FreeNormProtoList(LIST CharList)