tesseract  4.00.00dev
lstmeval.cpp File Reference
#include "base/commandlineflags.h"
#include "commontraining.h"
#include "genericvector.h"
#include "lstmtester.h"
#include "strngs.h"
#include "tprintf.h"

Go to the source code of this file.

Functions

 STRING_PARAM_FLAG (model, "", "Name of model file (training or recognition)")
 
 STRING_PARAM_FLAG (eval_listfile, "", "File listing sample files in lstmf training format.")
 
 INT_PARAM_FLAG (max_image_MB, 2000, "Max memory to use for images.")
 
int main (int argc, char **argv)
 

Function Documentation

◆ INT_PARAM_FLAG()

INT_PARAM_FLAG ( max_image_MB  ,
2000  ,
"Max memory to use for images."   
)

◆ 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 33 of file lstmeval.cpp.

33  {
34  ParseArguments(&argc, &argv);
35  if (FLAGS_model.empty()) {
36  tprintf("Must provide a --model!\n");
37  return 1;
38  }
39  if (FLAGS_eval_listfile.empty()) {
40  tprintf("Must provide a --eval_listfile!\n");
41  return 1;
42  }
43  GenericVector<char> model_data;
44  if (!tesseract::LoadDataFromFile(FLAGS_model.c_str(), &model_data)) {
45  tprintf("Failed to load model from: %s\n", FLAGS_eval_listfile.c_str());
46  return 1;
47  }
48  tesseract::LSTMTester tester(static_cast<inT64>(FLAGS_max_image_MB) *
49  1048576);
50  if (!tester.LoadAllEvalData(FLAGS_eval_listfile.c_str())) {
51  tprintf("Failed to load eval data from: %s\n", FLAGS_eval_listfile.c_str());
52  return 1;
53  }
54  double errs = 0.0;
55  STRING result = tester.RunEvalSync(0, &errs, model_data, 0);
56  tprintf("%s\n", result.string());
57  return 0;
58 } /* main */
#define tprintf(...)
Definition: tprintf.h:31
const char * string() const
Definition: strngs.cpp:198
void ParseArguments(int *argc, char ***argv)
Definition: strngs.h:45
bool LoadDataFromFile(const char *filename, GenericVector< char > *data)

◆ STRING_PARAM_FLAG() [1/2]

STRING_PARAM_FLAG ( model  ,
""  ,
"Name of model file (training or recognition)"   
)

◆ STRING_PARAM_FLAG() [2/2]

STRING_PARAM_FLAG ( eval_listfile  ,
""  ,
"File listing sample files in lstmf training format."   
)