Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve disabled legacy engine build #3120

Merged
merged 4 commits into from
Oct 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ libtesseract_la_SOURCES += src/arch/simddetect.cpp
# Rules for src/ccmain.

noinst_HEADERS += src/ccmain/control.h
noinst_HEADERS += src/ccmain/equationdetect.h
noinst_HEADERS += src/ccmain/mutableiterator.h
noinst_HEADERS += src/ccmain/output.h
noinst_HEADERS += src/ccmain/paragraphs.h
Expand All @@ -208,6 +207,7 @@ noinst_HEADERS += src/ccmain/tessvars.h
noinst_HEADERS += src/ccmain/werdit.h
if !DISABLED_LEGACY_ENGINE
noinst_HEADERS += src/ccmain/docqual.h
noinst_HEADERS += src/ccmain/equationdetect.h
noinst_HEADERS += src/ccmain/fixspace.h
noinst_HEADERS += src/ccmain/reject.h
endif
Expand Down
4 changes: 2 additions & 2 deletions doc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ man_MANS = \
set_unicharset_properties.1 \
tesseract.1 \
text2image.1 \
unicharambigs.5 \
unicharset.5 \
unicharset_extractor.1 \
wordlist2dawg.1

Expand All @@ -23,7 +23,7 @@ man_MANS += \
cntraining.1 \
mftraining.1 \
shapeclustering.1 \
unicharset.5
unicharambigs.5
endif

man_xslt = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
Expand Down
2 changes: 2 additions & 0 deletions src/api/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
#include "edgblob.h" // for extract_edges
#include "elst.h" // for ELIST_ITERATOR, ELISTIZE, ELISTIZEH
#include "environ.h" // for l_uint8
#ifndef DISABLED_LEGACY_ENGINE
#include "equationdetect.h" // for EquationDetect
#endif
#include "errcode.h" // for ASSERT_HOST
#include <tesseract/helpers.h> // for IntCastRounded, chomp_string
#include "imageio.h" // for IFF_TIFF_G4, IFF_TIFF, IFF_TIFF_G3, ...
Expand Down
4 changes: 4 additions & 0 deletions src/ccmain/pagesegmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
#include "blread.h"
#include "colfind.h"
#include "debugpixa.h"
#ifndef DISABLED_LEGACY_ENGINE
#include "equationdetect.h"
#endif
#include "imagefind.h"
#include "linefind.h"
#include "makerow.h"
Expand Down Expand Up @@ -219,9 +221,11 @@ int Tesseract::AutoPageSeg(PageSegMode pageseg_mode, BLOCK_LIST* blocks,
// blocks separately. For now combine with photomask_pix.
pixOr(photomask_pix, photomask_pix, musicmask_pix);
}
#ifndef DISABLED_LEGACY_ENGINE
if (equ_detect_) {
finder->SetEquationDetect(equ_detect_);
}
#endif // ndef DISABLED_LEGACY_ENGINE
result = finder->FindBlocks(pageseg_mode, scaled_color_, scaled_factor_,
to_block, photomask_pix, pix_thresholds_,
pix_grey_, &pixa_debug_, &found_blocks,
Expand Down
2 changes: 2 additions & 0 deletions src/ccmain/tesseractclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@

#include "allheaders.h"
#include "edgblob.h"
#ifndef DISABLED_LEGACY_ENGINE
#include "equationdetect.h"
#endif
#ifndef ANDROID_BUILD
#include "lstmrecognizer.h"
#endif
Expand Down
6 changes: 6 additions & 0 deletions src/textord/colfind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
#include "ccnontextdetect.h"
#include "colpartition.h"
#include "colpartitionset.h"
#ifndef DISABLED_LEGACY_ENGINE
#include "equationdetectbase.h"
#endif
#include "linefind.h"
#include "normalis.h"
#include "strokewidth.h"
Expand Down Expand Up @@ -414,9 +416,11 @@ int ColumnFinder::FindBlocks(PageSegMode pageseg_mode, Pix* scaled_color,
}
#endif
if (!PSM_SPARSE(pageseg_mode)) {
#ifndef DISABLED_LEGACY_ENGINE
if (equation_detect_) {
equation_detect_->FindEquationParts(&part_grid_, best_columns_);
}
#endif
if (textord_tabfind_find_tables) {
TableFinder table_finder;
table_finder.Init(gridsize(), bleft(), tright());
Expand Down Expand Up @@ -506,9 +510,11 @@ void ColumnFinder::GetDeskewVectors(FCOORD* deskew, FCOORD* reskew) {
deskew->set_y(-deskew->y());
}

#ifndef DISABLED_LEGACY_ENGINE
void ColumnFinder::SetEquationDetect(EquationDetectBase* detect) {
equation_detect_ = detect;
}
#endif

//////////////// PRIVATE CODE /////////////////////////

Expand Down
32 changes: 31 additions & 1 deletion unittest/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ AM_CPPFLAGS += -isystem $(top_srcdir)/googletest/googletest/include \

check_PROGRAMS = apiexample_test
if ENABLE_TRAINING
if !DISABLED_LEGACY_ENGINE
check_PROGRAMS += applybox_test
endif # !DISABLED_LEGACY_ENGINE
check_PROGRAMS += baseapi_test
if TENSORFLOW
check_PROGRAMS += baseapi_thread_test
Expand All @@ -141,8 +143,8 @@ check_PROGRAMS += heap_test
check_PROGRAMS += imagedata_test
if !DISABLED_LEGACY_ENGINE
check_PROGRAMS += indexmapbidi_test
endif # !DISABLED_LEGACY_ENGINE
check_PROGRAMS += intfeaturemap_test
endif # !DISABLED_LEGACY_ENGINE
check_PROGRAMS += intsimdmatrix_test
check_PROGRAMS += lang_model_test
check_PROGRAMS += layout_test
Expand All @@ -155,7 +157,9 @@ check_PROGRAMS += lstm_test
check_PROGRAMS += lstmtrainer_test
endif # ENABLE_TRAINING
check_PROGRAMS += loadlang_test
if !DISABLED_LEGACY_ENGINE
check_PROGRAMS += mastertrainer_test
endif # !DISABLED_LEGACY_ENGINE
check_PROGRAMS += matrix_test
if TENSORFLOW
check_PROGRAMS += networkio_test
Expand All @@ -164,22 +168,28 @@ if ENABLE_TRAINING
check_PROGRAMS += normstrngs_test
endif # ENABLE_TRAINING
check_PROGRAMS += nthitem_test
if !DISABLED_LEGACY_ENGINE
check_PROGRAMS += osd_test
endif # !DISABLED_LEGACY_ENGINE
check_PROGRAMS += pagesegmode_test
if ENABLE_TRAINING
if TENSORFLOW
check_PROGRAMS += pango_font_info_test
endif # TENSORFLOW
endif # ENABLE_TRAINING
check_PROGRAMS += paragraphs_test
if !DISABLED_LEGACY_ENGINE
check_PROGRAMS += params_model_test
endif # !DISABLED_LEGACY_ENGINE
check_PROGRAMS += progress_test
check_PROGRAMS += qrsequence_test
check_PROGRAMS += recodebeam_test
check_PROGRAMS += rect_test
check_PROGRAMS += resultiterator_test
check_PROGRAMS += scanutils_test
if !DISABLED_LEGACY_ENGINE
check_PROGRAMS += shapetable_test
endif # !DISABLED_LEGACY_ENGINE
check_PROGRAMS += stats_test
if TENSORFLOW
check_PROGRAMS += stridemap_test
Expand Down Expand Up @@ -219,8 +229,10 @@ apiexample_test_SOURCES = apiexample_test.cc
apiexample_test_LDFLAGS = $(OPENCL_LDFLAGS) $(LEPTONICA_LIBS)
apiexample_test_LDADD = $(TESS_LIBS) $(LEPTONICA_LIBS)

if !DISABLED_LEGACY_ENGINE
applybox_test_SOURCES = applybox_test.cc
applybox_test_LDADD = $(TRAINING_LIBS) $(LEPTONICA_LIBS)
endif # !DISABLED_LEGACY_ENGINE

baseapi_test_SOURCES = baseapi_test.cc
baseapi_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS) $(LEPTONICA_LIBS)
Expand All @@ -231,8 +243,10 @@ baseapi_thread_test_LDADD = $(ABSEIL_LIBS)
baseapi_thread_test_LDADD += $(TESS_LIBS) $(LEPTONICA_LIBS)
endif # TENSORFLOW

if !DISABLED_LEGACY_ENGINE
bitvector_test_SOURCES = bitvector_test.cc
bitvector_test_LDADD = $(TRAINING_LIBS)
endif # !DISABLED_LEGACY_ENGINE

cleanapi_test_SOURCES = cleanapi_test.cc
cleanapi_test_LDADD = $(TESS_LIBS)
Expand All @@ -249,10 +263,12 @@ dawg_test_LDADD = $(TRAINING_LIBS)
denorm_test_SOURCES = denorm_test.cc
denorm_test_LDADD = $(TESS_LIBS)

if !DISABLED_LEGACY_ENGINE
if TENSORFLOW
equationdetect_test_SOURCES = equationdetect_test.cc
equationdetect_test_LDADD = $(TESS_LIBS) $(LEPTONICA_LIBS)
endif # TENSORFLOW
endif # !DISABLED_LEGACY_ENGINE

fileio_test_SOURCES = fileio_test.cc
fileio_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS)
Expand All @@ -263,11 +279,15 @@ heap_test_LDADD = $(TESS_LIBS)
imagedata_test_SOURCES = imagedata_test.cc
imagedata_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS)

if !DISABLED_LEGACY_ENGINE
indexmapbidi_test_SOURCES = indexmapbidi_test.cc
indexmapbidi_test_LDADD = $(TRAINING_LIBS)
endif # !DISABLED_LEGACY_ENGINE

if !DISABLED_LEGACY_ENGINE
intfeaturemap_test_SOURCES = intfeaturemap_test.cc
intfeaturemap_test_LDADD = $(TRAINING_LIBS)
endif # !DISABLED_LEGACY_ENGINE

intsimdmatrix_test_SOURCES = intsimdmatrix_test.cc
intsimdmatrix_test_LDADD = $(TESS_LIBS)
Expand Down Expand Up @@ -309,8 +329,10 @@ lstm_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS)
lstmtrainer_test_SOURCES = lstmtrainer_test.cc
lstmtrainer_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS) $(LEPTONICA_LIBS)

if !DISABLED_LEGACY_ENGINE
mastertrainer_test_SOURCES = mastertrainer_test.cc
mastertrainer_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS) $(LEPTONICA_LIBS)
endif # !DISABLED_LEGACY_ENGINE

matrix_test_SOURCES = matrix_test.cc
matrix_test_LDADD = $(TESS_LIBS)
Expand All @@ -329,8 +351,10 @@ normstrngs_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS) $(ICU_I18N_LIBS) $(ICU_U
nthitem_test_SOURCES = nthitem_test.cc
nthitem_test_LDADD = $(TESS_LIBS)

if !DISABLED_LEGACY_ENGINE
osd_test_SOURCES = osd_test.cc
osd_test_LDADD = $(TESS_LIBS) $(LEPTONICA_LIBS)
endif # !DISABLED_LEGACY_ENGINE

pagesegmode_test_SOURCES = pagesegmode_test.cc
pagesegmode_test_LDADD = $(TRAINING_LIBS) $(LEPTONICA_LIBS)
Expand All @@ -348,8 +372,10 @@ endif # TENSORFLOW
paragraphs_test_SOURCES = paragraphs_test.cc
paragraphs_test_LDADD = $(ABSEIL_LIBS) $(TESS_LIBS)

if !DISABLED_LEGACY_ENGINE
params_model_test_SOURCES = params_model_test.cc
params_model_test_LDADD = $(TRAINING_LIBS)
endif # !DISABLED_LEGACY_ENGINE

progress_test_SOURCES = progress_test.cc
progress_test_LDFLAGS = $(OPENCL_LDFLAGS) $(LEPTONICA_LIBS)
Expand All @@ -371,8 +397,10 @@ resultiterator_test_LDADD += $(LEPTONICA_LIBS) $(ICU_I18N_LIBS) $(ICU_UC_LIBS)
scanutils_test_SOURCES = scanutils_test.cc
scanutils_test_LDADD = $(TRAINING_LIBS)

if !DISABLED_LEGACY_ENGINE
shapetable_test_SOURCES = shapetable_test.cc
shapetable_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS)
endif # !DISABLED_LEGACY_ENGINE

stats_test_SOURCES = stats_test.cc
stats_test_LDADD = $(TESS_LIBS)
Expand Down Expand Up @@ -439,7 +467,9 @@ if T_WIN
apiexample_test_LDADD += -lws2_32
intsimdmatrix_test_LDADD += -lws2_32
matrix_test_LDADD += -lws2_32
if !DISABLED_LEGACY_ENGINE
osd_test_LDADD += -lws2_32
endif # !DISABLED_LEGACY_ENGINE
loadlang_test_LDADD += -lws2_32
endif

Expand Down