All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tesseract::CharClassifierFactory Class Reference

#include <classifier_factory.h>

Static Public Member Functions

static CharClassifierCreate (const string &data_file_path, const string &lang, LangModel *lang_mod, CharSet *char_set, TuningParams *params)
 

Detailed Description

Definition at line 31 of file classifier_factory.h.

Member Function Documentation

CharClassifier * tesseract::CharClassifierFactory::Create ( const string &  data_file_path,
const string &  lang,
LangModel lang_mod,
CharSet char_set,
TuningParams params 
)
static

Definition at line 35 of file classifier_factory.cpp.

39  {
40  // create the feature extraction object
41  FeatureBase *feat_extract;
42 
43  switch (params->TypeFeature()) {
44  case TuningParams::BMP:
45  feat_extract = new FeatureBmp(params);
46  break;
48  feat_extract = new FeatureChebyshev(params);
49  break;
51  feat_extract = new FeatureHybrid(params);
52  break;
53  default:
54  fprintf(stderr, "Cube ERROR (CharClassifierFactory::Create): invalid "
55  "feature type.\n");
56  return NULL;
57  }
58 
59  if (feat_extract == NULL) {
60  fprintf(stderr, "Cube ERROR (CharClassifierFactory::Create): unable "
61  "to instantiate feature extraction object.\n");
62  return NULL;
63  }
64 
65  // create the classifier object
66  CharClassifier *classifier_obj;
67  switch (params->TypeClassifier()) {
68  case TuningParams::NN:
69  classifier_obj = new ConvNetCharClassifier(char_set, params,
70  feat_extract);
71  break;
73  classifier_obj = new HybridNeuralNetCharClassifier(char_set, params,
74  feat_extract);
75  break;
76  default:
77  fprintf(stderr, "Cube ERROR (CharClassifierFactory::Create): invalid "
78  "classifier type.\n");
79  return NULL;
80  }
81 
82  if (classifier_obj == NULL) {
83  fprintf(stderr, "Cube ERROR (CharClassifierFactory::Create): error "
84  "allocating memory for character classifier object.\n");
85  return NULL;
86  }
87 
88  // Init the classifier
89  if (!classifier_obj->Init(data_file_path, lang, lang_mod)) {
90  delete classifier_obj;
91  fprintf(stderr, "Cube ERROR (CharClassifierFactory::Create): unable "
92  "to Init() character classifier object.\n");
93  return NULL;
94  }
95  return classifier_obj;
96 }
#define NULL
Definition: host.h:144

The documentation for this class was generated from the following files: