From 4b6db074623ac87c63b74be6db02f11bea1a11cd Mon Sep 17 00:00:00 2001 From: amitdo Date: Sat, 10 Oct 2020 01:33:27 +0300 Subject: [PATCH 1/4] Improve disabled legacy engine build --- doc/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/Makefile.am b/doc/Makefile.am index b8cf07ac4e..f78e5e00f2 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -12,7 +12,7 @@ man_MANS = \ set_unicharset_properties.1 \ tesseract.1 \ text2image.1 \ - unicharambigs.5 \ + unicharset.5 \ unicharset_extractor.1 \ wordlist2dawg.1 @@ -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 From f4744de78b542066bbfd4fa6acec17d4207c0268 Mon Sep 17 00:00:00 2001 From: amitdo Date: Sat, 10 Oct 2020 02:20:51 +0300 Subject: [PATCH 2/4] Improve disabled legacy engine build --- unittest/Makefile.am | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/unittest/Makefile.am b/unittest/Makefile.am index 71f938903c..32f84ef639 100644 --- a/unittest/Makefile.am +++ b/unittest/Makefile.am @@ -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 @@ -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 @@ -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 @@ -164,7 +168,9 @@ 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 @@ -172,14 +178,18 @@ 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 @@ -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) @@ -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) @@ -263,11 +277,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) @@ -309,8 +327,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) @@ -329,8 +349,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) @@ -348,8 +370,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) @@ -371,8 +395,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) @@ -439,7 +465,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 From 50ca49a91750ad705823d25f5c5a4a577bd841ca Mon Sep 17 00:00:00 2001 From: amitdo Date: Sat, 10 Oct 2020 02:53:38 +0300 Subject: [PATCH 3/4] Improve disabled legacy engine build --- unittest/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/unittest/Makefile.am b/unittest/Makefile.am index 32f84ef639..167ecb3e6a 100644 --- a/unittest/Makefile.am +++ b/unittest/Makefile.am @@ -263,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) From b378ebff2e460d088fe00bbb1b1de3b67c408481 Mon Sep 17 00:00:00 2001 From: amitdo Date: Sat, 10 Oct 2020 04:49:52 +0300 Subject: [PATCH 4/4] Improve disabled legacy engine build --- Makefile.am | 2 +- src/api/baseapi.cpp | 2 ++ src/ccmain/pagesegmain.cpp | 4 ++++ src/ccmain/tesseractclass.cpp | 2 ++ src/textord/colfind.cpp | 6 ++++++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 46021d5d9b..939c47242a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 @@ -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 diff --git a/src/api/baseapi.cpp b/src/api/baseapi.cpp index 610773dc7b..264810a396 100644 --- a/src/api/baseapi.cpp +++ b/src/api/baseapi.cpp @@ -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 // for IntCastRounded, chomp_string #include "imageio.h" // for IFF_TIFF_G4, IFF_TIFF, IFF_TIFF_G3, ... diff --git a/src/ccmain/pagesegmain.cpp b/src/ccmain/pagesegmain.cpp index b962504228..d03466ac82 100644 --- a/src/ccmain/pagesegmain.cpp +++ b/src/ccmain/pagesegmain.cpp @@ -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" @@ -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, diff --git a/src/ccmain/tesseractclass.cpp b/src/ccmain/tesseractclass.cpp index 4d0e4111bb..299413b442 100644 --- a/src/ccmain/tesseractclass.cpp +++ b/src/ccmain/tesseractclass.cpp @@ -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 diff --git a/src/textord/colfind.cpp b/src/textord/colfind.cpp index 38be6c62c8..e305a2c3b6 100644 --- a/src/textord/colfind.cpp +++ b/src/textord/colfind.cpp @@ -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" @@ -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()); @@ -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 /////////////////////////