Improve the disable legacy build (#3624)

Disable more code related to equation detection and osd.
This commit is contained in:
Amit D 2021-11-03 20:15:15 +02:00 committed by GitHub
parent 5da09f241c
commit e9b8b840bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 2 deletions

View File

@ -49,7 +49,9 @@ class UNICHARSET;
class Dawg;
class Dict;
#ifndef DISABLED_LEGACY_ENGINE
class EquationDetect;
#endif // ndef DISABLED_LEGACY_ENGINE
class PageIterator;
class ImageThresholder;
class LTRResultIterator;
@ -766,7 +768,9 @@ protected:
protected:
Tesseract *tesseract_; ///< The underlying data object.
Tesseract *osd_tesseract_; ///< For orientation & script detection.
#ifndef DISABLED_LEGACY_ENGINE
EquationDetect *equ_detect_; ///< The equation detector.
#endif // ndef DISABLED_LEGACY_ENGINE
FileReader reader_; ///< Reads files from any filesystem.
ImageThresholder *thresholder_; ///< Image thresholding module.
std::vector<ParagraphModel *> *paragraph_models_;

View File

@ -29,7 +29,9 @@
#include "dict.h" // for Dict
#include "elst.h" // for ELIST_ITERATOR, ELISTIZE, ELISTIZEH
#include "environ.h" // for l_uint8
#ifndef DISABLED_LEGACY_ENGINE
#include "equationdetect.h" // for EquationDetect, destructor of equ_detect_
#endif // ndef DISABLED_LEGACY_ENGINE
#include "errcode.h" // for ASSERT_HOST
#include "helpers.h" // for IntCastRounded, chomp_string
#include "host.h" // for MAX_PATH
@ -206,7 +208,9 @@ static void addAvailableLanguages(const std::string &datadir, const std::string
TessBaseAPI::TessBaseAPI()
: tesseract_(nullptr)
, osd_tesseract_(nullptr)
#ifndef DISABLED_LEGACY_ENGINE
, equ_detect_(nullptr)
#endif // ndef DISABLED_LEGACY_ENGINE
, reader_(nullptr)
,
// thresholder_ is initialized to nullptr here, but will be set before use
@ -1889,15 +1893,17 @@ void TessBaseAPI::End() {
delete paragraph_models_;
paragraph_models_ = nullptr;
}
#ifndef DISABLED_LEGACY_ENGINE
if (osd_tesseract_ == tesseract_) {
osd_tesseract_ = nullptr;
}
delete tesseract_;
tesseract_ = nullptr;
delete osd_tesseract_;
osd_tesseract_ = nullptr;
delete equ_detect_;
equ_detect_ = nullptr;
#endif // ndef DISABLED_LEGACY_ENGINE
delete tesseract_;
tesseract_ = nullptr;
input_file_.clear();
output_file_.clear();
datapath_.clear();
@ -2119,6 +2125,7 @@ int TessBaseAPI::FindLines() {
Tesseract *osd_tess = osd_tesseract_;
OSResults osr;
#ifndef DISABLED_LEGACY_ENGINE
if (PSM_OSD_ENABLED(tesseract_->tessedit_pageseg_mode) && osd_tess == nullptr) {
if (strcmp(language_.c_str(), "osd") == 0) {
osd_tess = tesseract_;
@ -2144,6 +2151,7 @@ int TessBaseAPI::FindLines() {
}
}
}
#endif // ndef DISABLED_LEGACY_ENGINE
if (tesseract_->SegmentPage(input_file_.c_str(), block_list_, osd_tess, &osr) < 0) {
return -1;

View File

@ -400,7 +400,9 @@ Tesseract::Tesseract()
"instance is not going to be used for OCR but say only "
"for layout analysis.",
this->params())
#ifndef DISABLED_LEGACY_ENGINE
, BOOL_MEMBER(textord_equation_detect, false, "Turn on equation detector", this->params())
#endif // ndef DISABLED_LEGACY_ENGINE
, BOOL_MEMBER(textord_tabfind_vertical_text, true, "Enable vertical detection", this->params())
, BOOL_MEMBER(textord_tabfind_force_vertical_text, false, "Force using vertical text page mode",
this->params())
@ -452,7 +454,9 @@ Tesseract::Tesseract()
, reskew_(1.0f, 0.0f)
, most_recently_used_(this)
, font_table_size_(0)
#ifndef DISABLED_LEGACY_ENGINE
, equ_detect_(nullptr)
#endif // ndef DISABLED_LEGACY_ENGINE
, lstm_recognizer_(nullptr)
, train_line_page_num_(0) {}

View File

@ -69,7 +69,9 @@ class WERD_RES;
class ColumnFinder;
class DocumentData;
#ifndef DISABLED_LEGACY_ENGINE
class EquationDetect;
#endif // ndef DISABLED_LEGACY_ENGINE
class ImageData;
class LSTMRecognizer;
class Tesseract;
@ -189,8 +191,10 @@ public:
// Clear the document dictionary for this and all subclassifiers.
void ResetDocumentDictionary();
#ifndef DISABLED_LEGACY_ENGINE
// Set the equation detector.
void SetEquationDetect(EquationDetect *detector);
#endif // ndef DISABLED_LEGACY_ENGINE
// Simple accessors.
const FCOORD &reskew() const {
@ -942,7 +946,9 @@ public:
BOOL_VAR_H(textord_use_cjk_fp_model);
BOOL_VAR_H(poly_allow_detailed_fx);
BOOL_VAR_H(tessedit_init_config_only);
#ifndef DISABLED_LEGACY_ENGINE
BOOL_VAR_H(textord_equation_detect);
#endif // ndef DISABLED_LEGACY_ENGINE
BOOL_VAR_H(textord_tabfind_vertical_text);
BOOL_VAR_H(textord_tabfind_force_vertical_text);
double_VAR_H(textord_tabfind_vertical_text_ratio);
@ -1001,8 +1007,10 @@ private:
Tesseract *most_recently_used_;
// The size of the font table, ie max possible font id + 1.
int font_table_size_;
#ifndef DISABLED_LEGACY_ENGINE
// Equation detector. Note: this pointer is NOT owned by the class.
EquationDetect *equ_detect_;
#endif // ndef DISABLED_LEGACY_ENGINE
// LSTM recognizer, if available.
LSTMRecognizer *lstm_recognizer_;
// Output "page" number (actually line number) using TrainLineRecognizer.