tesseract  3.05.02
classifier_tester.cpp File Reference
#include <stdio.h>
#include "base/commandlineflags.h"
#include "baseapi.h"
#include "commontraining.h"
#include "cubeclassifier.h"
#include "mastertrainer.h"
#include "params.h"
#include "strngs.h"
#include "tessclassifier.h"

Go to the source code of this file.

Enumerations

enum  ClassifierName {
  CN_PRUNER, CN_FULL, CN_CUBE, CN_CUBETESS,
  CN_COUNT
}
 

Functions

 STRING_PARAM_FLAG (classifier, "", "Classifier to test")
 
 STRING_PARAM_FLAG (lang, "eng", "Language to test")
 
 STRING_PARAM_FLAG (tessdata_dir, "", "Directory of traineddata files")
 
 DECLARE_INT_PARAM_FLAG (debug_level)
 
 DECLARE_STRING_PARAM_FLAG (T)
 
int main (int argc, char **argv)
 

Variables

const char * names []
 

Enumeration Type Documentation

◆ ClassifierName

Enumerator
CN_PRUNER 
CN_FULL 
CN_CUBE 
CN_CUBETESS 
CN_COUNT 

Definition at line 39 of file classifier_tester.cpp.

39  {
40  CN_PRUNER,
41  CN_FULL,
42 #ifndef NO_CUBE_BUILD
43  CN_CUBE,
45 #endif // NO_CUBE_BUILD
46  CN_COUNT
47 };

Function Documentation

◆ DECLARE_INT_PARAM_FLAG()

DECLARE_INT_PARAM_FLAG ( debug_level  )

◆ DECLARE_STRING_PARAM_FLAG()

DECLARE_STRING_PARAM_FLAG ( )

◆ main()

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 149 of file classifier_tester.cpp.

149  {
150  ParseArguments(&argc, &argv);
151  STRING file_prefix;
153  argc, argv, false, NULL, &file_prefix);
155  // Decode the classifier string.
156  tesseract::ShapeClassifier* shape_classifier = InitializeClassifier(
157  FLAGS_classifier.c_str(), trainer->unicharset(), argc, argv, &api);
158  if (shape_classifier == NULL) {
159  fprintf(stderr, "Classifier init failed!:%s\n", FLAGS_classifier.c_str());
160  return 1;
161  }
162 
163  // We want to test junk as well if it is available.
164  // trainer->IncludeJunk();
165  // We want to test with replicated samples too.
167 
169  MAX(3, FLAGS_debug_level), false,
170  shape_classifier, NULL);
171  delete shape_classifier;
172  delete api;
173  delete trainer;
174 
175  return 0;
176 } /* main */
void ParseArguments(int *argc, char ***argv)
void TestClassifierOnSamples(CountTypes error_mode, int report_level, bool replicate_samples, ShapeClassifier *test_classifier, STRING *report_string)
void ReplicateAndRandomizeSamplesIfRequired()
MasterTrainer * LoadTrainingData(int argc, const char *const *argv, bool replication, ShapeTable **shape_table, STRING *file_prefix)
#define MAX(x, y)
Definition: ndminx.h:24
Definition: strngs.h:44
const UNICHARSET & unicharset() const

◆ STRING_PARAM_FLAG() [1/3]

STRING_PARAM_FLAG ( classifier  ,
""  ,
"Classifier to test"   
)

◆ STRING_PARAM_FLAG() [2/3]

STRING_PARAM_FLAG ( lang  ,
"eng"  ,
"Language to test"   
)

◆ STRING_PARAM_FLAG() [3/3]

STRING_PARAM_FLAG ( tessdata_dir  ,
""  ,
"Directory of traineddata files"   
)

Variable Documentation

◆ names

const char* names[]
Initial value:
= {"pruner", "full",
"cube", "cubetess",
NULL}

Definition at line 49 of file classifier_tester.cpp.