diff --git a/api/baseapi.cpp b/api/baseapi.cpp index 7b16794e33..375401af39 100644 --- a/api/baseapi.cpp +++ b/api/baseapi.cpp @@ -743,53 +743,6 @@ void TessBaseAPI::DumpPGM(const char* filename) { fclose(fp); } -#ifndef NO_CUBE_BUILD -/** - * Placeholder for call to Cube and test that the input data is correct. - * reskew is the direction of baselines in the skewed image in - * normalized (cos theta, sin theta) form, so (0.866, 0.5) would represent - * a 30 degree anticlockwise skew. - */ -int CubeAPITest(Boxa* boxa_blocks, Pixa* pixa_blocks, - Boxa* boxa_words, Pixa* pixa_words, - const FCOORD& reskew, Pix* page_pix, - PAGE_RES* page_res) { - int block_count = boxaGetCount(boxa_blocks); - ASSERT_HOST(block_count == pixaGetCount(pixa_blocks)); - // Write each block to the current directory as junk_write_display.nnn.png. - for (int i = 0; i < block_count; ++i) { - Pix* pix = pixaGetPix(pixa_blocks, i, L_CLONE); - pixDisplayWrite(pix, 1); - } - int word_count = boxaGetCount(boxa_words); - ASSERT_HOST(word_count == pixaGetCount(pixa_words)); - int pr_word = 0; - PAGE_RES_IT page_res_it(page_res); - for (page_res_it.restart_page(); page_res_it.word () != NULL; - page_res_it.forward(), ++pr_word) { - WERD_RES *word = page_res_it.word(); - WERD_CHOICE* choice = word->best_choice; - // Write the first 100 words to files names wordims/.tif. - if (pr_word < 100) { - STRING filename("wordims/"); - if (choice != NULL) { - filename += choice->unichar_string(); - } else { - char numbuf[32]; - filename += "unclassified"; - snprintf(numbuf, 32, "%03d", pr_word); - filename += numbuf; - } - filename += ".tif"; - Pix* pix = pixaGetPix(pixa_words, pr_word, L_CLONE); - pixWrite(filename.string(), pix, IFF_TIFF_G4); - } - } - ASSERT_HOST(pr_word == word_count); - return 0; -} -#endif // NO_CUBE_BUILD - /** * Runs page layout analysis in the mode set by SetPageSegMode. * May optionally be called prior to Recognize to get access to just @@ -1893,13 +1846,16 @@ char* TessBaseAPI::GetUNLVText() { /** * Detect the orientation of the input image and apparent script (alphabet). - * orient_deg is the detected clockwise rotation of the input image in degrees (0, 90, 180, 270) + * orient_deg is the detected clockwise rotation of the input image in degrees + * (0, 90, 180, 270) * orient_conf is the confidence (15.0 is reasonably confident) * script_name is an ASCII string, the name of the script, e.g. "Latin" * script_conf is confidence level in the script * Returns true on success and writes values to each parameter as an output */ -bool TessBaseAPI::DetectOrientationScript(int* orient_deg, float* orient_conf, const char** script_name, float* script_conf) { +bool TessBaseAPI::DetectOrientationScript(int* orient_deg, float* orient_conf, + const char** script_name, + float* script_conf) { OSResults osr; bool osd = DetectOS(&osr); @@ -1909,21 +1865,17 @@ bool TessBaseAPI::DetectOrientationScript(int* orient_deg, float* orient_conf, c int orient_id = osr.best_result.orientation_id; int script_id = osr.get_best_script(orient_id); - if (orient_conf) - *orient_conf = osr.best_result.oconfidence; - if (orient_deg) - *orient_deg = orient_id * 90; // convert quadrant to degrees + if (orient_conf) *orient_conf = osr.best_result.oconfidence; + if (orient_deg) *orient_deg = orient_id * 90; // convert quadrant to degrees if (script_name) { - const char* script = - osr.unicharset->get_script_from_script_id(script_id); + const char* script = osr.unicharset->get_script_from_script_id(script_id); *script_name = script; } - if (script_conf) - *script_conf = osr.best_result.sconfidence; - + if (script_conf) *script_conf = osr.best_result.sconfidence; + return true; } @@ -1938,7 +1890,8 @@ char* TessBaseAPI::GetOsdText(int page_number) { const char* script_name; float script_conf; - if (!DetectOrientationScript(&orient_deg, &orient_conf, &script_name, &script_conf)) + if (!DetectOrientationScript(&orient_deg, &orient_conf, &script_name, + &script_conf)) return NULL; // clockwise rotation needed to make the page upright @@ -2250,8 +2203,8 @@ void TessBaseAPI::Threshold(Pix** pix) { if (y_res < kMinCredibleResolution || y_res > kMaxCredibleResolution) { // Use the minimum default resolution, as it is safer to under-estimate // than over-estimate resolution. - tprintf("Warning. Invalid resolution %d dpi. Using %d instead.\n", - y_res, kMinCredibleResolution); + tprintf("Warning. Invalid resolution %d dpi. Using %d instead.\n", y_res, + kMinCredibleResolution); thresholder_->SetSourceYResolution(kMinCredibleResolution); } PageSegMode pageseg_mode = @@ -2857,13 +2810,6 @@ int TessBaseAPI::NumDawgs() const { return tesseract_ == NULL ? 0 : tesseract_->getDict().NumDawgs(); } -#ifndef NO_CUBE_BUILD -/** Return a pointer to underlying CubeRecoContext object if present. */ -CubeRecoContext *TessBaseAPI::GetCubeRecoContext() const { - return (tesseract_ == NULL) ? NULL : tesseract_->GetCubeRecoContext(); -} -#endif // NO_CUBE_BUILD - /** Escape a char string - remove <>&"' with HTML codes. */ STRING HOcrEscape(const char* text) { STRING ret; diff --git a/api/baseapi.h b/api/baseapi.h index b7e9ba1368..f68f8d59f8 100644 --- a/api/baseapi.h +++ b/api/baseapi.h @@ -65,9 +65,6 @@ struct TBLOB; namespace tesseract { -#ifndef NO_CUBE_BUILD -class CubeRecoContext; -#endif // NO_CUBE_BUILD class Dawg; class Dict; class EquationDetect; @@ -620,13 +617,15 @@ class TESS_API TessBaseAPI { /** * Detect the orientation of the input image and apparent script (alphabet). - * orient_deg is the detected clockwise rotation of the input image in degrees (0, 90, 180, 270) + * orient_deg is the detected clockwise rotation of the input image in degrees + * (0, 90, 180, 270) * orient_conf is the confidence (15.0 is reasonably confident) * script_name is an ASCII string, the name of the script, e.g. "Latin" * script_conf is confidence level in the script * Returns true on success and writes values to each parameter as an output */ - bool DetectOrientationScript(int* orient_deg, float* orient_conf, const char** script_name, float* script_conf); + bool DetectOrientationScript(int* orient_deg, float* orient_conf, + const char** script_name, float* script_conf); /** * The recognized text is returned as a char* which is coded @@ -762,11 +761,6 @@ class TESS_API TessBaseAPI { void InitTruthCallback(TruthCallback *cb) { truth_cb_ = cb; } -#ifndef NO_CUBE_BUILD - /** Return a pointer to underlying CubeRecoContext object if present. */ - CubeRecoContext *GetCubeRecoContext() const; -#endif // NO_CUBE_BUILD - void set_min_orientation_margin(double margin); /** diff --git a/ccmain/control.cpp b/ccmain/control.cpp index eed343516e..4e433addd5 100644 --- a/ccmain/control.cpp +++ b/ccmain/control.cpp @@ -405,15 +405,6 @@ bool Tesseract::recog_all_words(PAGE_RES* page_res, // ****************** Pass 5,6 ******************* rejection_passes(page_res, monitor, target_word_box, word_config); -#ifndef NO_CUBE_BUILD - // ****************** Pass 7 ******************* - // Cube combiner. - // If cube is loaded and its combiner is present, run it. - if (tessedit_ocr_engine_mode == OEM_TESSERACT_CUBE_COMBINED) { - run_cube_combiner(page_res); - } -#endif - // ****************** Pass 8 ******************* font_recognition_pass(page_res); @@ -887,7 +878,7 @@ int Tesseract::RetryWithLanguage(const WordData& word_data, WordRecognizer recognizer, WERD_RES** in_word, PointerVector* best_words) { - bool debug = classify_debug_level || cube_debug_level; + bool debug = classify_debug_level; if (debug) { tprintf("Trying word using lang %s, oem %d\n", lang.string(), static_cast(tessedit_ocr_engine_mode)); @@ -906,8 +897,7 @@ int Tesseract::RetryWithLanguage(const WordData& word_data, new_words[i]->DebugTopChoice("Lang result"); } // Initial version is a bit of a hack based on better certainty and rating - // (to reduce false positives from cube) or a dictionary vs non-dictionary - // word. + // or a dictionary vs non-dictionary word. return SelectBestWords(classify_max_rating_ratio, classify_max_certainty_margin, debug, &new_words, best_words); @@ -1291,7 +1281,7 @@ void Tesseract::classify_word_and_language(int pass_n, PAGE_RES_IT* pr_it, // Points to the best result. May be word or in lang_words. WERD_RES* word = word_data->word; clock_t start_t = clock(); - if (classify_debug_level || cube_debug_level) { + if (classify_debug_level) { tprintf("%s word with lang %s at:", word->done ? "Already done" : "Processing", most_recently_used_->lang.string()); @@ -1365,13 +1355,6 @@ void Tesseract::classify_word_pass1(const WordData& word_data, BLOCK* block = word_data.block; prev_word_best_choice_ = word_data.prev_word != NULL ? word_data.prev_word->word->best_choice : NULL; -#ifndef NO_CUBE_BUILD - // If we only intend to run cube - run it and return. - if (tessedit_ocr_engine_mode == OEM_CUBE_ONLY) { - cube_word_pass1(block, row, *in_word); - return; - } -#endif #ifndef ANDROID_BUILD if (tessedit_ocr_engine_mode == OEM_LSTM_ONLY || tessedit_ocr_engine_mode == OEM_TESSERACT_LSTM_COMBINED) { diff --git a/ccmain/par_control.cpp b/ccmain/par_control.cpp index 82cd55c9a0..be8d356397 100644 --- a/ccmain/par_control.cpp +++ b/ccmain/par_control.cpp @@ -20,7 +20,7 @@ #include "tesseractclass.h" #ifdef _OPENMP #include -#endif // _OPENMP +#endif // _OPENMP namespace tesseract { @@ -54,8 +54,8 @@ void Tesseract::PrerecAllWordsPar(const GenericVector& words) { // Pre-classify all the blobs. if (tessedit_parallelize > 1) { #ifdef _OPENMP - #pragma omp parallel for num_threads(10) -#endif // _OPENMP +#pragma omp parallel for num_threads(10) +#endif // _OPENMP for (int b = 0; b < blobs.size(); ++b) { *blobs[b].choices = blobs[b].tesseract->classify_blob(blobs[b].blob, "par", White, NULL); diff --git a/ccmain/paramsd.h b/ccmain/paramsd.h index c45cebd41c..931fc1195c 100644 --- a/ccmain/paramsd.h +++ b/ccmain/paramsd.h @@ -24,9 +24,6 @@ #define VARABLED_H #include "elst.h" -#ifndef NO_CUBE_BUILD -#include "scrollview.h" -#endif #include "params.h" #include "tesseractclass.h" diff --git a/ccmain/tessedit.cpp b/ccmain/tessedit.cpp index 340ac0c391..45c37335fb 100644 --- a/ccmain/tessedit.cpp +++ b/ccmain/tessedit.cpp @@ -243,17 +243,6 @@ bool Tesseract::init_tesseract_lang_data( ambigs_debug_level, use_ambigs_for_adaption, &unicharset); if (tessdata_manager_debug_level) tprintf("Loaded ambigs\n"); } -#ifndef NO_CUBE_BUILD - if (tessedit_ocr_engine_mode == OEM_CUBE_ONLY) { - ASSERT_HOST(init_cube_objects(false, &tessdata_manager)); - if (tessdata_manager_debug_level) - tprintf("Loaded Cube w/out combiner\n"); - } else if (tessedit_ocr_engine_mode == OEM_TESSERACT_CUBE_COMBINED) { - ASSERT_HOST(init_cube_objects(true, &tessdata_manager)); - if (tessdata_manager_debug_level) - tprintf("Loaded Cube with combiner\n"); - } -#endif // Init ParamsModel. // Load pass1 and pass2 weights (for now these two sets are the same, but in // the future separate sets of weights can be generated). @@ -446,14 +435,8 @@ int Tesseract::init_tesseract_internal( } // If only LSTM will be used, skip loading Tesseract classifier's // pre-trained templates and dictionary. - bool init_tesseract = tessedit_ocr_engine_mode != OEM_LSTM_ONLY && - tessedit_ocr_engine_mode != OEM_CUBE_ONLY; - bool init_dict = init_tesseract; - if (tessedit_ocr_engine_mode == OEM_CUBE_ONLY && - !tessdata_manager.SeekToStart(TESSDATA_CUBE_UNICHARSET)) { - init_dict = true; - } - program_editup(textbase, init_tesseract, init_dict); + bool init_tesseract = tessedit_ocr_engine_mode != OEM_LSTM_ONLY; + program_editup(textbase, init_tesseract, init_tesseract); tessdata_manager.End(); return 0; //Normal exit } diff --git a/ccmain/tesseractclass.cpp b/ccmain/tesseractclass.cpp index ed6c1338ba..491da195b9 100644 --- a/ccmain/tesseractclass.cpp +++ b/ccmain/tesseractclass.cpp @@ -42,15 +42,11 @@ #include "tesseractclass.h" #include "allheaders.h" -#ifndef NO_CUBE_BUILD -#include "cube_reco_context.h" -#endif #include "edgblob.h" #include "equationdetect.h" #include "globals.h" -#ifndef NO_CUBE_BUILD +#ifndef ANDROID_BUILD #include "lstmrecognizer.h" -#include "tesseract_cube_combiner.h" #endif namespace tesseract { @@ -224,7 +220,6 @@ Tesseract::Tesseract() "Run paragraph detection on the post-text-recognition " "(more accurate)", this->params()), - INT_MEMBER(cube_debug_level, 0, "Print cube debug info.", this->params()), BOOL_MEMBER(lstm_use_matrix, 1, "Use ratings matrix/beam search with lstm", this->params()), STRING_MEMBER(outlines_odd, "%| ", "Non standard number of outlines", @@ -608,7 +603,6 @@ Tesseract::Tesseract() backup_config_file_(NULL), pix_binary_(NULL), - cube_binary_(NULL), pix_grey_(NULL), pix_original_(NULL), pix_thresholds_(NULL), @@ -621,10 +615,6 @@ Tesseract::Tesseract() reskew_(1.0f, 0.0f), most_recently_used_(this), font_table_size_(0), -#ifndef NO_CUBE_BUILD - cube_cntxt_(NULL), - tess_cube_combiner_(NULL), -#endif equ_detect_(NULL), #ifndef ANDROID_BUILD lstm_recognizer_(NULL), @@ -637,16 +627,7 @@ Tesseract::~Tesseract() { pixDestroy(&pix_original_); end_tesseract(); sub_langs_.delete_data_pointers(); -#ifndef NO_CUBE_BUILD - // Delete cube objects. - if (cube_cntxt_ != NULL) { - delete cube_cntxt_; - cube_cntxt_ = NULL; - } - if (tess_cube_combiner_ != NULL) { - delete tess_cube_combiner_; - tess_cube_combiner_ = NULL; - } +#ifndef ANDROID_BUILD delete lstm_recognizer_; lstm_recognizer_ = NULL; #endif @@ -654,7 +635,6 @@ Tesseract::~Tesseract() { void Tesseract::Clear() { pixDestroy(&pix_binary_); - pixDestroy(&cube_binary_); pixDestroy(&pix_grey_); pixDestroy(&pix_thresholds_); pixDestroy(&scaled_color_); @@ -704,8 +684,6 @@ void Tesseract::SetBlackAndWhitelist() { // page segmentation. void Tesseract::PrepareForPageseg() { textord_.set_use_cjk_fp_model(textord_use_cjk_fp_model); - pixDestroy(&cube_binary_); - cube_binary_ = pixClone(pix_binary()); // Find the max splitter strategy over all langs. ShiroRekhaSplitter::SplitStrategy max_pageseg_strategy = static_cast( @@ -716,9 +694,6 @@ void Tesseract::PrepareForPageseg() { static_cast(sub_langs_[i]->pageseg_devanagari_split_strategy)); if (pageseg_strategy > max_pageseg_strategy) max_pageseg_strategy = pageseg_strategy; - // Clone the cube image to all the sub langs too. - pixDestroy(&sub_langs_[i]->cube_binary_); - sub_langs_[i]->cube_binary_ = pixClone(pix_binary()); pixDestroy(&sub_langs_[i]->pix_binary_); sub_langs_[i]->pix_binary_ = pixClone(pix_binary()); } diff --git a/ccmain/tesseractclass.h b/ccmain/tesseractclass.h index 47c9dd7e50..aa9421958e 100644 --- a/ccmain/tesseractclass.h +++ b/ccmain/tesseractclass.h @@ -76,8 +76,7 @@ class WERD_RES; // WordRec (wordrec/wordrec.h) // ^ Members include: WERD*, DENORM* // Tesseract (ccmain/tesseractclass.h) -// Members include: Pix*, CubeRecoContext*, -// TesseractCubeCombiner* +// Members include: Pix* // // Other important classes: // @@ -96,20 +95,11 @@ class WERD_RES; namespace tesseract { class ColumnFinder; -#ifndef NO_CUBE_BUILD -class CharSamp; -class CubeLineObject; -class CubeObject; -class CubeRecoContext; -#endif class DocumentData; class EquationDetect; class ImageData; class LSTMRecognizer; class Tesseract; -#ifndef NO_CUBE_BUILD -class TesseractCubeCombiner; -#endif // A collection of various variables for statistics and debugging. struct TesseractStats { @@ -486,34 +476,6 @@ class Tesseract : public Wordrec { int *left_ok, int *right_ok) const; - //// cube_control.cpp /////////////////////////////////////////////////// -#ifndef NO_CUBE_BUILD - bool init_cube_objects(bool load_combiner, - TessdataManager *tessdata_manager); - // Iterates through tesseract's results and calls cube on each word, - // combining the results with the existing tesseract result. - void run_cube_combiner(PAGE_RES *page_res); - // Recognizes a single word using (only) cube. Compatible with - // Tesseract's classify_word_pass1/classify_word_pass2. - void cube_word_pass1(BLOCK* block, ROW *row, WERD_RES *word); - // Cube recognizer to recognize a single word as with classify_word_pass1 - // but also returns the cube object in case the combiner is needed. - CubeObject* cube_recognize_word(BLOCK* block, WERD_RES* word); - // Combines the cube and tesseract results for a single word, leaving the - // result in tess_word. - void cube_combine_word(CubeObject* cube_obj, WERD_RES* cube_word, - WERD_RES* tess_word); - // Call cube on the current word, and write the result to word. - // Sets up a fake result and returns false if something goes wrong. - bool cube_recognize(CubeObject *cube_obj, BLOCK* block, WERD_RES *word); - void fill_werd_res(const BoxWord& cube_box_word, - const char* cube_best_str, - WERD_RES* tess_werd_res); - bool extract_cube_state(CubeObject* cube_obj, int* num_chars, - Boxa** char_boxes, CharSamp*** char_samples); - bool create_cube_box_word(Boxa *char_boxes, int num_chars, - TBOX word_box, BoxWord* box_word); -#endif //// output.h ////////////////////////////////////////////////////////// void output_pass(PAGE_RES_IT &page_res_it, const TBOX *target_word_box); @@ -949,7 +911,6 @@ class Tesseract : public Wordrec { BOOL_VAR_H(paragraph_text_based, true, "Run paragraph detection on the post-text-recognition " "(more accurate)"); - INT_VAR_H(cube_debug_level, 1, "Print cube debug info."); BOOL_VAR_H(lstm_use_matrix, 1, "Use ratings matrix/beam searct with lstm"); STRING_VAR_H(outlines_odd, "%| ", "Non standard number of outlines"); STRING_VAR_H(outlines_2, "ij!?%\":;", "Non standard number of outlines"); @@ -1216,10 +1177,6 @@ class Tesseract : public Wordrec { PAGE_RES_IT* pr_it, FILE *output_file); -#ifndef NO_CUBE_BUILD - inline CubeRecoContext *GetCubeRecoContext() { return cube_cntxt_; } -#endif - private: // The filename of a backup config file. If not null, then we currently // have a temporary debug config file loaded, and backup_config_file_ @@ -1230,8 +1187,6 @@ class Tesseract : public Wordrec { // Image used for input to layout analysis and tesseract recognition. // May be modified by the ShiroRekhaSplitter to eliminate the top-line. Pix* pix_binary_; - // Unmodified image used for input to cube. Always valid. - Pix* cube_binary_; // Grey-level input image if the input was not binary, otherwise NULL. Pix* pix_grey_; // Original input image. Color if the input was color. @@ -1260,11 +1215,6 @@ class Tesseract : public Wordrec { Tesseract* most_recently_used_; // The size of the font table, ie max possible font id + 1. int font_table_size_; -#ifndef NO_CUBE_BUILD - // Cube objects. - CubeRecoContext* cube_cntxt_; - TesseractCubeCombiner *tess_cube_combiner_; -#endif // Equation detector. Note: this pointer is NOT owned by the class. EquationDetect* equ_detect_; // LSTM recognizer, if available. diff --git a/ccstruct/blobs.cpp b/ccstruct/blobs.cpp index ad4994079e..f5b427ecfe 100644 --- a/ccstruct/blobs.cpp +++ b/ccstruct/blobs.cpp @@ -815,12 +815,10 @@ void TWERD::BLNormalize(const BLOCK* block, const ROW* row, Pix* pix, float input_y_offset = 0.0f; float final_y_offset = static_cast(kBlnBaselineOffset); float scale = kBlnXHeight / x_height; - if (hint == tesseract::OEM_CUBE_ONLY || row == NULL) { + if (row == NULL) { word_middle = word_box.left(); input_y_offset = word_box.bottom(); final_y_offset = 0.0f; - if (hint == tesseract::OEM_CUBE_ONLY) - scale = 1.0f; } else { input_y_offset = row->base_line(word_middle) + baseline_shift; } @@ -834,7 +832,7 @@ void TWERD::BLNormalize(const BLOCK* block, const ROW* row, Pix* pix, baseline = blob_box.bottom(); blob_scale = ClipToRange(kBlnXHeight * 4.0f / (3 * blob_box.height()), scale, scale * 1.5f); - } else if (row != NULL && hint != tesseract::OEM_CUBE_ONLY) { + } else if (row != NULL) { baseline = row->base_line(mid_x) + baseline_shift; } // The image will be 8-bit grey if the input was grey or color. Note that in diff --git a/ccstruct/pageres.cpp b/ccstruct/pageres.cpp index 2e0ec8d625..894102cd05 100644 --- a/ccstruct/pageres.cpp +++ b/ccstruct/pageres.cpp @@ -303,9 +303,9 @@ bool WERD_RES::SetupForRecognition(const UNICHARSET& unicharset_in, static_cast(norm_mode); tesseract = tess; POLY_BLOCK* pb = block != NULL ? block->poly_block() : NULL; - if ((norm_mode_hint != tesseract::OEM_CUBE_ONLY && - norm_mode_hint != tesseract::OEM_LSTM_ONLY && - word->cblob_list()->empty()) || (pb != NULL && !pb->IsText())) { + if ((norm_mode_hint != tesseract::OEM_LSTM_ONLY && + word->cblob_list()->empty()) || + (pb != NULL && !pb->IsText())) { // Empty words occur when all the blobs have been moved to the rej_blobs // list, which seems to occur frequently in junk. SetupFake(unicharset_in); diff --git a/ccstruct/rejctmap.cpp b/ccstruct/rejctmap.cpp index a2910675a8..2123230e52 100644 --- a/ccstruct/rejctmap.cpp +++ b/ccstruct/rejctmap.cpp @@ -267,10 +267,10 @@ void REJ::full_print(FILE *fp) { //The REJMAP class has been hacked to use alloc_struct instead of new []. //This is to reduce memory fragmentation only as it is rather kludgy. -//alloc_struct by-passes the call to the constructor of REJ on each -//array element. Although the constructor is empty, the BITS16 members -//do have a constructor which sets all the flags to 0. The memset -//replaces this functionality. +// alloc_struct by-passes the call to the constructor of REJ on each +// array element. Although the constructor is empty, the BITS16 members +// do have a constructor which sets all the flags to 0. The memset +// replaces this functionality. REJMAP::REJMAP( //classwise copy const REJMAP &source) { diff --git a/training/classifier_tester.cpp b/training/classifier_tester.cpp index ed7e50cd2f..ada9f75e06 100644 --- a/training/classifier_tester.cpp +++ b/training/classifier_tester.cpp @@ -22,9 +22,6 @@ #endif // USE_STD_NAMESPACE #include "baseapi.h" #include "commontraining.h" -#ifndef NO_CUBE_BUILD -#include "cubeclassifier.h" -#endif // NO_CUBE_BUILD #include "mastertrainer.h" #include "params.h" #include "strngs.h" @@ -39,17 +36,10 @@ DECLARE_STRING_PARAM_FLAG(T); enum ClassifierName { CN_PRUNER, CN_FULL, -#ifndef NO_CUBE_BUILD - CN_CUBE, - CN_CUBETESS, -#endif // NO_CUBE_BUILD CN_COUNT }; const char* names[] = {"pruner", "full", -#ifndef NO_CUBE_BUILD - "cube", "cubetess", -#endif // NO_CUBE_BUILD NULL}; static tesseract::ShapeClassifier* InitializeClassifier( @@ -72,20 +62,10 @@ static tesseract::ShapeClassifier* InitializeClassifier( // We need to initialize tesseract to test. *api = new tesseract::TessBaseAPI; tesseract::OcrEngineMode engine_mode = tesseract::OEM_TESSERACT_ONLY; -#ifndef NO_CUBE_BUILD - if (classifier == CN_CUBE || classifier == CN_CUBETESS) - engine_mode = tesseract::OEM_TESSERACT_CUBE_COMBINED; -#endif // NO_CUBE_BUILD tesseract::Tesseract* tesseract = NULL; tesseract::Classify* classify = NULL; if ( -#ifndef NO_CUBE_BUILD - classifier == CN_CUBE || classifier == CN_CUBETESS || -#endif // NO_CUBE_BUILD classifier == CN_PRUNER || classifier == CN_FULL) { -#ifndef NO_CUBE_BUILD - (*api)->SetVariable("cube_debug_level", "2"); -#endif // NO_CUBE_BUILD if ((*api)->Init(FLAGS_tessdata_dir.c_str(), FLAGS_lang.c_str(), engine_mode) < 0) { fprintf(stderr, "Tesseract initialization failed!\n"); @@ -111,12 +91,6 @@ static tesseract::ShapeClassifier* InitializeClassifier( shape_classifier = new tesseract::TessClassifier(true, classify); } else if (classifier == CN_FULL) { shape_classifier = new tesseract::TessClassifier(false, classify); -#ifndef NO_CUBE_BUILD - } else if (classifier == CN_CUBE) { - shape_classifier = new tesseract::CubeClassifier(tesseract); - } else if (classifier == CN_CUBETESS) { - shape_classifier = new tesseract::CubeTessClassifier(tesseract); -#endif // NO_CUBE_BUILD } else { fprintf(stderr, "%s tester not yet implemented\n", classifer_name); return NULL; @@ -143,8 +117,6 @@ static tesseract::ShapeClassifier* InitializeClassifier( // Available values of classifier (x above) are: // pruner : Tesseract class pruner only. // full : Tesseract full classifier. -// cube : Cube classifier. (Not possible with an input trainer.) -// cubetess : Tesseract class pruner with rescoring by Cube. (Not possible // with an input trainer.) int main(int argc, char **argv) { ParseArguments(&argc, &argv);