mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-03 00:49:01 +08:00
Improve the disable legacy build (#3624)
Disable more code related to equation detection and osd.
This commit is contained in:
parent
5da09f241c
commit
e9b8b840bf
@ -49,7 +49,9 @@ class UNICHARSET;
|
|||||||
|
|
||||||
class Dawg;
|
class Dawg;
|
||||||
class Dict;
|
class Dict;
|
||||||
|
#ifndef DISABLED_LEGACY_ENGINE
|
||||||
class EquationDetect;
|
class EquationDetect;
|
||||||
|
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||||
class PageIterator;
|
class PageIterator;
|
||||||
class ImageThresholder;
|
class ImageThresholder;
|
||||||
class LTRResultIterator;
|
class LTRResultIterator;
|
||||||
@ -766,7 +768,9 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
Tesseract *tesseract_; ///< The underlying data object.
|
Tesseract *tesseract_; ///< The underlying data object.
|
||||||
Tesseract *osd_tesseract_; ///< For orientation & script detection.
|
Tesseract *osd_tesseract_; ///< For orientation & script detection.
|
||||||
|
#ifndef DISABLED_LEGACY_ENGINE
|
||||||
EquationDetect *equ_detect_; ///< The equation detector.
|
EquationDetect *equ_detect_; ///< The equation detector.
|
||||||
|
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||||
FileReader reader_; ///< Reads files from any filesystem.
|
FileReader reader_; ///< Reads files from any filesystem.
|
||||||
ImageThresholder *thresholder_; ///< Image thresholding module.
|
ImageThresholder *thresholder_; ///< Image thresholding module.
|
||||||
std::vector<ParagraphModel *> *paragraph_models_;
|
std::vector<ParagraphModel *> *paragraph_models_;
|
||||||
|
@ -29,7 +29,9 @@
|
|||||||
#include "dict.h" // for Dict
|
#include "dict.h" // for Dict
|
||||||
#include "elst.h" // for ELIST_ITERATOR, ELISTIZE, ELISTIZEH
|
#include "elst.h" // for ELIST_ITERATOR, ELISTIZE, ELISTIZEH
|
||||||
#include "environ.h" // for l_uint8
|
#include "environ.h" // for l_uint8
|
||||||
|
#ifndef DISABLED_LEGACY_ENGINE
|
||||||
#include "equationdetect.h" // for EquationDetect, destructor of equ_detect_
|
#include "equationdetect.h" // for EquationDetect, destructor of equ_detect_
|
||||||
|
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||||
#include "errcode.h" // for ASSERT_HOST
|
#include "errcode.h" // for ASSERT_HOST
|
||||||
#include "helpers.h" // for IntCastRounded, chomp_string
|
#include "helpers.h" // for IntCastRounded, chomp_string
|
||||||
#include "host.h" // for MAX_PATH
|
#include "host.h" // for MAX_PATH
|
||||||
@ -206,7 +208,9 @@ static void addAvailableLanguages(const std::string &datadir, const std::string
|
|||||||
TessBaseAPI::TessBaseAPI()
|
TessBaseAPI::TessBaseAPI()
|
||||||
: tesseract_(nullptr)
|
: tesseract_(nullptr)
|
||||||
, osd_tesseract_(nullptr)
|
, osd_tesseract_(nullptr)
|
||||||
|
#ifndef DISABLED_LEGACY_ENGINE
|
||||||
, equ_detect_(nullptr)
|
, equ_detect_(nullptr)
|
||||||
|
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||||
, reader_(nullptr)
|
, reader_(nullptr)
|
||||||
,
|
,
|
||||||
// thresholder_ is initialized to nullptr here, but will be set before use
|
// thresholder_ is initialized to nullptr here, but will be set before use
|
||||||
@ -1889,15 +1893,17 @@ void TessBaseAPI::End() {
|
|||||||
delete paragraph_models_;
|
delete paragraph_models_;
|
||||||
paragraph_models_ = nullptr;
|
paragraph_models_ = nullptr;
|
||||||
}
|
}
|
||||||
|
#ifndef DISABLED_LEGACY_ENGINE
|
||||||
if (osd_tesseract_ == tesseract_) {
|
if (osd_tesseract_ == tesseract_) {
|
||||||
osd_tesseract_ = nullptr;
|
osd_tesseract_ = nullptr;
|
||||||
}
|
}
|
||||||
delete tesseract_;
|
|
||||||
tesseract_ = nullptr;
|
|
||||||
delete osd_tesseract_;
|
delete osd_tesseract_;
|
||||||
osd_tesseract_ = nullptr;
|
osd_tesseract_ = nullptr;
|
||||||
delete equ_detect_;
|
delete equ_detect_;
|
||||||
equ_detect_ = nullptr;
|
equ_detect_ = nullptr;
|
||||||
|
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||||
|
delete tesseract_;
|
||||||
|
tesseract_ = nullptr;
|
||||||
input_file_.clear();
|
input_file_.clear();
|
||||||
output_file_.clear();
|
output_file_.clear();
|
||||||
datapath_.clear();
|
datapath_.clear();
|
||||||
@ -2119,6 +2125,7 @@ int TessBaseAPI::FindLines() {
|
|||||||
|
|
||||||
Tesseract *osd_tess = osd_tesseract_;
|
Tesseract *osd_tess = osd_tesseract_;
|
||||||
OSResults osr;
|
OSResults osr;
|
||||||
|
#ifndef DISABLED_LEGACY_ENGINE
|
||||||
if (PSM_OSD_ENABLED(tesseract_->tessedit_pageseg_mode) && osd_tess == nullptr) {
|
if (PSM_OSD_ENABLED(tesseract_->tessedit_pageseg_mode) && osd_tess == nullptr) {
|
||||||
if (strcmp(language_.c_str(), "osd") == 0) {
|
if (strcmp(language_.c_str(), "osd") == 0) {
|
||||||
osd_tess = tesseract_;
|
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) {
|
if (tesseract_->SegmentPage(input_file_.c_str(), block_list_, osd_tess, &osr) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -400,7 +400,9 @@ Tesseract::Tesseract()
|
|||||||
"instance is not going to be used for OCR but say only "
|
"instance is not going to be used for OCR but say only "
|
||||||
"for layout analysis.",
|
"for layout analysis.",
|
||||||
this->params())
|
this->params())
|
||||||
|
#ifndef DISABLED_LEGACY_ENGINE
|
||||||
, BOOL_MEMBER(textord_equation_detect, false, "Turn on equation detector", this->params())
|
, 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_vertical_text, true, "Enable vertical detection", this->params())
|
||||||
, BOOL_MEMBER(textord_tabfind_force_vertical_text, false, "Force using vertical text page mode",
|
, BOOL_MEMBER(textord_tabfind_force_vertical_text, false, "Force using vertical text page mode",
|
||||||
this->params())
|
this->params())
|
||||||
@ -452,7 +454,9 @@ Tesseract::Tesseract()
|
|||||||
, reskew_(1.0f, 0.0f)
|
, reskew_(1.0f, 0.0f)
|
||||||
, most_recently_used_(this)
|
, most_recently_used_(this)
|
||||||
, font_table_size_(0)
|
, font_table_size_(0)
|
||||||
|
#ifndef DISABLED_LEGACY_ENGINE
|
||||||
, equ_detect_(nullptr)
|
, equ_detect_(nullptr)
|
||||||
|
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||||
, lstm_recognizer_(nullptr)
|
, lstm_recognizer_(nullptr)
|
||||||
, train_line_page_num_(0) {}
|
, train_line_page_num_(0) {}
|
||||||
|
|
||||||
|
@ -69,7 +69,9 @@ class WERD_RES;
|
|||||||
|
|
||||||
class ColumnFinder;
|
class ColumnFinder;
|
||||||
class DocumentData;
|
class DocumentData;
|
||||||
|
#ifndef DISABLED_LEGACY_ENGINE
|
||||||
class EquationDetect;
|
class EquationDetect;
|
||||||
|
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||||
class ImageData;
|
class ImageData;
|
||||||
class LSTMRecognizer;
|
class LSTMRecognizer;
|
||||||
class Tesseract;
|
class Tesseract;
|
||||||
@ -189,8 +191,10 @@ public:
|
|||||||
// Clear the document dictionary for this and all subclassifiers.
|
// Clear the document dictionary for this and all subclassifiers.
|
||||||
void ResetDocumentDictionary();
|
void ResetDocumentDictionary();
|
||||||
|
|
||||||
|
#ifndef DISABLED_LEGACY_ENGINE
|
||||||
// Set the equation detector.
|
// Set the equation detector.
|
||||||
void SetEquationDetect(EquationDetect *detector);
|
void SetEquationDetect(EquationDetect *detector);
|
||||||
|
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||||
|
|
||||||
// Simple accessors.
|
// Simple accessors.
|
||||||
const FCOORD &reskew() const {
|
const FCOORD &reskew() const {
|
||||||
@ -942,7 +946,9 @@ public:
|
|||||||
BOOL_VAR_H(textord_use_cjk_fp_model);
|
BOOL_VAR_H(textord_use_cjk_fp_model);
|
||||||
BOOL_VAR_H(poly_allow_detailed_fx);
|
BOOL_VAR_H(poly_allow_detailed_fx);
|
||||||
BOOL_VAR_H(tessedit_init_config_only);
|
BOOL_VAR_H(tessedit_init_config_only);
|
||||||
|
#ifndef DISABLED_LEGACY_ENGINE
|
||||||
BOOL_VAR_H(textord_equation_detect);
|
BOOL_VAR_H(textord_equation_detect);
|
||||||
|
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||||
BOOL_VAR_H(textord_tabfind_vertical_text);
|
BOOL_VAR_H(textord_tabfind_vertical_text);
|
||||||
BOOL_VAR_H(textord_tabfind_force_vertical_text);
|
BOOL_VAR_H(textord_tabfind_force_vertical_text);
|
||||||
double_VAR_H(textord_tabfind_vertical_text_ratio);
|
double_VAR_H(textord_tabfind_vertical_text_ratio);
|
||||||
@ -1001,8 +1007,10 @@ private:
|
|||||||
Tesseract *most_recently_used_;
|
Tesseract *most_recently_used_;
|
||||||
// The size of the font table, ie max possible font id + 1.
|
// The size of the font table, ie max possible font id + 1.
|
||||||
int font_table_size_;
|
int font_table_size_;
|
||||||
|
#ifndef DISABLED_LEGACY_ENGINE
|
||||||
// Equation detector. Note: this pointer is NOT owned by the class.
|
// Equation detector. Note: this pointer is NOT owned by the class.
|
||||||
EquationDetect *equ_detect_;
|
EquationDetect *equ_detect_;
|
||||||
|
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||||
// LSTM recognizer, if available.
|
// LSTM recognizer, if available.
|
||||||
LSTMRecognizer *lstm_recognizer_;
|
LSTMRecognizer *lstm_recognizer_;
|
||||||
// Output "page" number (actually line number) using TrainLineRecognizer.
|
// Output "page" number (actually line number) using TrainLineRecognizer.
|
||||||
|
Loading…
Reference in New Issue
Block a user