tesseract  4.0.0-1-g2a2b
classifier_tester.cpp File Reference
#include <algorithm>
#include <cstdio>
#include "baseapi.h"
#include "commontraining.h"
#include "mastertrainer.h"
#include "params.h"
#include "strngs.h"
#include "tessclassifier.h"
#include "tesseractclass.h"

Go to the source code of this file.

Enumerations

enum  ClassifierName { CN_PRUNER, CN_FULL, 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)
 
int main (int argc, char **argv)
 

Enumeration Type Documentation

◆ ClassifierName

Enumerator
CN_PRUNER 
CN_FULL 
CN_COUNT 

Definition at line 37 of file classifier_tester.cpp.

Function Documentation

◆ DECLARE_INT_PARAM_FLAG()

DECLARE_INT_PARAM_FLAG ( debug_level  )

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 111 of file classifier_tester.cpp.

111  {
112  tesseract::CheckSharedLibraryVersion();
113  ParseArguments(&argc, &argv);
114  STRING file_prefix;
115  tesseract::MasterTrainer* trainer =
116  tesseract::LoadTrainingData(argc, argv, false, nullptr, &file_prefix);
118  // Decode the classifier string.
119  tesseract::ShapeClassifier* shape_classifier = InitializeClassifier(
120  FLAGS_classifier.c_str(), trainer->unicharset(), argc, argv, &api);
121  if (shape_classifier == nullptr) {
122  fprintf(stderr, "Classifier init failed!:%s\n", FLAGS_classifier.c_str());
123  return 1;
124  }
125 
126  // We want to test junk as well if it is available.
127  // trainer->IncludeJunk();
128  // We want to test with replicated samples too.
130 
132  std::max(3, static_cast<int>(FLAGS_debug_level)), false,
133  shape_classifier, nullptr);
134  delete shape_classifier;
135  delete api;
136  delete trainer;
137 
138  return 0;
139 } /* main */
const UNICHARSET & unicharset() const
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()
Definition: strngs.h:45
MasterTrainer * LoadTrainingData(int argc, const char *const *argv, bool replication, ShapeTable **shape_table, STRING *file_prefix)

◆ 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"   
)