All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
shapeclustering.cpp File Reference
#include "base/commandlineflags.h"
#include "commontraining.h"
#include "mastertrainer.h"
#include "params.h"
#include "strngs.h"

Go to the source code of this file.

Functions

 INT_PARAM_FLAG (display_cloud_font,-1,"Display cloud of this font, canonical_class1")
 
 INT_PARAM_FLAG (display_canonical_font,-1,"Display canonical sample of this font, canonical_class2")
 
 STRING_PARAM_FLAG (canonical_class1,"","Class to show ambigs for")
 
 STRING_PARAM_FLAG (canonical_class2,"","Class to show ambigs for")
 
int main (int argc, char **argv)
 

Function Documentation

INT_PARAM_FLAG ( display_cloud_font  ,
1,
"Display cloud of this  font,
canonical_class1"   
)
INT_PARAM_FLAG ( display_canonical_font  ,
1,
"Display canonical sample of this  font,
canonical_class2"   
)
int main ( int  argc,
char **  argv 
)

This program reads in a text file consisting of feature samples from a training page in the following format:

   FontName UTF8-char-str xmin ymin xmax ymax page-number
    NumberOfFeatureTypes(N)
      FeatureTypeName1 NumberOfFeatures(M)
         Feature1
         ...
         FeatureM
      FeatureTypeName2 NumberOfFeatures(M)
         Feature1
         ...
         FeatureM
      ...
      FeatureTypeNameN NumberOfFeatures(M)
         Feature1
         ...
         FeatureM
   FontName CharName ...

The result of this program is a binary inttemp file used by the OCR engine.

Parameters
argcnumber of command line arguments
argvarray of command line arguments
Returns
none
Note
Exceptions: none
History: Fri Aug 18 08:56:17 1989, DSJ, Created.
History: Mon May 18 1998, Christy Russson, Revistion started.

Definition at line 47 of file shapeclustering.cpp.

47  {
48  ParseArguments(&argc, &argv);
49 
50  STRING file_prefix;
52  argc, argv, false, NULL, &file_prefix);
53 
54  if (!trainer)
55  return 1;
56 
57  if (FLAGS_display_cloud_font >= 0) {
58 #ifndef GRAPHICS_DISABLED
59  trainer->DisplaySamples(FLAGS_canonical_class1.c_str(),
60  FLAGS_display_cloud_font,
61  FLAGS_canonical_class2.c_str(),
62  FLAGS_display_canonical_font);
63 #endif // GRAPHICS_DISABLED
64  return 0;
65  } else if (!FLAGS_canonical_class1.empty()) {
66  trainer->DebugCanonical(FLAGS_canonical_class1.c_str(),
67  FLAGS_canonical_class2.c_str());
68  return 0;
69  }
70  trainer->SetupMasterShapes();
71  WriteShapeTable(file_prefix, trainer->master_shapes());
72  delete trainer;
73 
74  return 0;
75 } /* main */
void DisplaySamples(const char *unichar_str1, int cloud_font, const char *unichar_str2, int canonical_font)
void ParseArguments(int *argc, char ***argv)
const ShapeTable & master_shapes() const
MasterTrainer * LoadTrainingData(int argc, const char *const *argv, bool replication, ShapeTable **shape_table, STRING *file_prefix)
Definition: strngs.h:44
#define NULL
Definition: host.h:144
void DebugCanonical(const char *unichar_str1, const char *unichar_str2)
void WriteShapeTable(const STRING &file_prefix, const ShapeTable &shape_table)
STRING_PARAM_FLAG ( canonical_class1  ,
""  ,
"Class to show ambigs for"   
)
STRING_PARAM_FLAG ( canonical_class2  ,
""  ,
"Class to show ambigs for"   
)