Tesseract
3.02
|
#include <classifier_factory.h>
Static Public Member Functions | |
static CharClassifier * | Create (const string &data_file_path, const string &lang, LangModel *lang_mod, CharSet *char_set, TuningParams *params) |
Definition at line 31 of file classifier_factory.h.
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.
{ // create the feature extraction object FeatureBase *feat_extract; switch (params->TypeFeature()) { case TuningParams::BMP: feat_extract = new FeatureBmp(params); break; case TuningParams::CHEBYSHEV: feat_extract = new FeatureChebyshev(params); break; case TuningParams::HYBRID: feat_extract = new FeatureHybrid(params); break; default: fprintf(stderr, "Cube ERROR (CharClassifierFactory::Create): invalid " "feature type.\n"); return NULL; } if (feat_extract == NULL) { fprintf(stderr, "Cube ERROR (CharClassifierFactory::Create): unable " "to instantiate feature extraction object.\n"); return NULL; } // create the classifier object CharClassifier *classifier_obj; switch (params->TypeClassifier()) { case TuningParams::NN: classifier_obj = new ConvNetCharClassifier(char_set, params, feat_extract); break; case TuningParams::HYBRID_NN: classifier_obj = new HybridNeuralNetCharClassifier(char_set, params, feat_extract); break; default: fprintf(stderr, "Cube ERROR (CharClassifierFactory::Create): invalid " "classifier type.\n"); return NULL; } if (classifier_obj == NULL) { fprintf(stderr, "Cube ERROR (CharClassifierFactory::Create): error " "allocating memory for character classifier object.\n"); return NULL; } // Init the classifier if (!classifier_obj->Init(data_file_path, lang, lang_mod)) { delete classifier_obj; fprintf(stderr, "Cube ERROR (CharClassifierFactory::Create): unable " "to Init() character classifier object.\n"); return NULL; } return classifier_obj; }