Skip to content

Commit

Permalink
implement build without cube (-DNO_CUBE_BUILD)
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenop committed Jul 24, 2015
1 parent 4085f91 commit 41478fd
Show file tree
Hide file tree
Showing 17 changed files with 103 additions and 58 deletions.
6 changes: 5 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ endif

.PHONY: install-langs ScrollView.jar install-jars $(TRAINING_SUBDIR)

SUBDIRS = ccutil viewer cutil opencl ccstruct dict classify wordrec neural_networks/runtime textord cube ccmain api . tessdata doc
SUBDIRS = ccutil viewer cutil opencl ccstruct dict classify wordrec textord
if !NO_CUBE_BUILD
SUBDIRS += neural_networks/runtime cube
endif
SUBDIRS += ccmain api . tessdata doc

EXTRA_DIST = ReleaseNotes \
aclocal.m4 config configure.ac autogen.sh contrib \
Expand Down
2 changes: 1 addition & 1 deletion android/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES:$(LOCAL_PATH)/%=%)
$(info local src files = $(LOCAL_SRC_FILES))

LOCAL_LDLIBS := -ldl -llog -ljnigraphics
LOCAL_CFLAGS := -DANDROID_BUILD -DGRAPHICS_DISABLED
LOCAL_CFLAGS := -DNO_CUBE_BUILD -DGRAPHICS_DISABLED

include $(BUILD_SHARED_LIBRARY)

Expand Down
17 changes: 11 additions & 6 deletions api/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ lib_LTLIBRARIES += libtesseract_api.la
libtesseract_api_la_LDFLAGS = -version-info $(GENERIC_LIBRARY_VERSION)
libtesseract_api_la_LIBADD = \
../ccmain/libtesseract_main.la \
../cube/libtesseract_cube.la \
../neural_networks/runtime/libtesseract_neural.la \
../textord/libtesseract_textord.la \
../wordrec/libtesseract_wordrec.la \
../classify/libtesseract_classify.la \
Expand All @@ -34,13 +32,17 @@ libtesseract_api_la_LIBADD = \
../viewer/libtesseract_viewer.la \
../ccutil/libtesseract_ccutil.la \
../opencl/libtesseract_opencl.la

if !NO_CUBE_BUILD
libtesseract_api_la_LIBADD += ../cube/libtesseract_cube.la \
../neural_networks/runtime/libtesseract_neural.la \
endif
endif

libtesseract_api_la_CPPFLAGS = $(AM_CPPFLAGS)
if VISIBILITY
libtesseract_api_la_CPPFLAGS += -DTESS_EXPORTS
endif
libtesseract_api_la_SOURCES = baseapi.cpp capi.cpp pdfrenderer.cpp renderer.cpp
libtesseract_api_la_SOURCES = baseapi.cpp capi.cpp renderer.cpp

lib_LTLIBRARIES += libtesseract.la
libtesseract_la_LDFLAGS =
Expand All @@ -51,8 +53,6 @@ nodist_EXTRA_libtesseract_la_SOURCES = dummy.cxx
libtesseract_la_LIBADD = \
libtesseract_api.la \
../ccmain/libtesseract_main.la \
../cube/libtesseract_cube.la \
../neural_networks/runtime/libtesseract_neural.la \
../textord/libtesseract_textord.la \
../wordrec/libtesseract_wordrec.la \
../classify/libtesseract_classify.la \
Expand All @@ -62,6 +62,11 @@ libtesseract_la_LIBADD = \
../viewer/libtesseract_viewer.la \
../ccutil/libtesseract_ccutil.la \
../opencl/libtesseract_opencl.la
if !NO_CUBE_BUILD
libtesseract_api_la_SOURCES += pdfrenderer.cpp
libtesseract_la_LIBADD += ../cube/libtesseract_cube.la \
../neural_networks/runtime/libtesseract_neural.la
endif

libtesseract_la_LDFLAGS += -version-info $(GENERIC_LIBRARY_VERSION)

Expand Down
10 changes: 5 additions & 5 deletions api/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ void TessBaseAPI::DumpPGM(const char* filename) {
fclose(fp);
}

#ifndef ANDROID_BUILD
#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
Expand Down Expand Up @@ -1029,7 +1029,7 @@ bool TessBaseAPI::ProcessPagesMultipageTiff(const l_uint8 *data,
int timeout_millisec,
TessResultRenderer* renderer,
int tessedit_page_number) {
#ifndef ANDROID_BUILD
#ifndef NO_CUBE_BUILD
Pix *pix = NULL;
#ifdef USE_OPENCL
OpenclDevice od;
Expand Down Expand Up @@ -1098,7 +1098,7 @@ bool TessBaseAPI::ProcessPagesInternal(const char* filename,
const char* retry_config,
int timeout_millisec,
TessResultRenderer* renderer) {
#ifndef ANDROID_BUILD
#ifndef NO_CUBE_BUILD
PERF_COUNT_START("ProcessPages")
bool stdInput = !strcmp(filename, "stdin") || !strcmp(filename, "-");
if (stdInput) {
Expand Down Expand Up @@ -1222,7 +1222,7 @@ bool TessBaseAPI::ProcessPage(Pix* pix, int page_index, const char* filename,
failed = Recognize(NULL) < 0;
}
if (tesseract_->tessedit_write_images) {
#ifndef ANDROID_BUILD
#ifndef NO_CUBE_BUILD
Pix* page_pix = GetThresholdedImage();
pixWrite("tessinput.tif", page_pix, IFF_TIFF_G4);
#endif
Expand Down Expand Up @@ -2633,7 +2633,7 @@ int TessBaseAPI::NumDawgs() const {
return tesseract_ == NULL ? 0 : tesseract_->getDict().NumDawgs();
}

#ifndef ANDROID_BUILD
#ifndef NO_CUBE_BUILD
/** Return a pointer to underlying CubeRecoContext object if present. */
CubeRecoContext *TessBaseAPI::GetCubeRecoContext() const {
return (tesseract_ == NULL) ? NULL : tesseract_->GetCubeRecoContext();
Expand Down
4 changes: 4 additions & 0 deletions api/capi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ TESS_API TessResultRenderer* TESS_CALL TessHOcrRendererCreate2(const char* outpu
return new TessHOcrRenderer(outputbase, font_info);
}

#ifndef NO_CUBE_BUILD
TESS_API TessResultRenderer* TESS_CALL TessPDFRendererCreate(const char* outputbase, const char* datadir)
{
return new TessPDFRenderer(outputbase, datadir);
}
#endif

TESS_API TessResultRenderer* TESS_CALL TessUnlvRendererCreate(const char* outputbase)
{
Expand Down Expand Up @@ -581,10 +583,12 @@ TESS_API void TESS_CALL TessBaseAPIInitTruthCallback(TessBaseAPI* handle, TessTr
handle->InitTruthCallback(cb);
}

#ifndef NO_CUBE_BUILD
TESS_API TessCubeRecoContext* TESS_CALL TessBaseAPIGetCubeRecoContext(const TessBaseAPI* handle)
{
return handle->GetCubeRecoContext();
}
#endif // NO_CUBE_BUILD

TESS_API void TESS_CALL TessBaseAPISetMinOrientationMargin(TessBaseAPI* handle, double margin)
{
Expand Down
6 changes: 6 additions & 0 deletions api/capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ extern "C" {
typedef tesseract::TessResultRenderer TessResultRenderer;
typedef tesseract::TessTextRenderer TessTextRenderer;
typedef tesseract::TessHOcrRenderer TessHOcrRenderer;
#ifndef NO_CUBE_BUILD
typedef tesseract::TessPDFRenderer TessPDFRenderer;
#endif // NO_CUBE_BUILD
typedef tesseract::TessUnlvRenderer TessUnlvRenderer;
typedef tesseract::TessBoxTextRenderer TessBoxTextRenderer;
typedef tesseract::TessBaseAPI TessBaseAPI;
Expand All @@ -51,7 +53,9 @@ typedef tesseract::ProbabilityInContextFunc TessProbabilityInContextFunc;
typedef tesseract::FillLatticeFunc TessFillLatticeFunc;
typedef tesseract::Dawg TessDawg;
typedef tesseract::TruthCallback TessTruthCallback;
#ifndef NO_CUBE_BUILD
typedef tesseract::CubeRecoContext TessCubeRecoContext;
#endif // NO_CUBE_BUILD
typedef tesseract::Orientation TessOrientation;
typedef tesseract::ParagraphJustification TessParagraphJustification;
typedef tesseract::WritingDirection TessWritingDirection;
Expand Down Expand Up @@ -295,8 +299,10 @@ TESS_API TessOcrEngineMode
TESS_CALL TessBaseAPIOem(const TessBaseAPI* handle);
TESS_API void TESS_CALL TessBaseAPIInitTruthCallback(TessBaseAPI* handle, TessTruthCallback* cb);

#ifndef NO_CUBE_BUILD
TESS_API TessCubeRecoContext*
TESS_CALL TessBaseAPIGetCubeRecoContext(const TessBaseAPI* handle);
#endif // NO_CUBE_BUILD
#endif

TESS_API void TESS_CALL TessBaseAPISetMinOrientationMargin(TessBaseAPI* handle, double margin);
Expand Down
2 changes: 2 additions & 0 deletions api/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class TESS_API TessHOcrRenderer : public TessResultRenderer {
bool font_info_; // whether to print font information
};

#ifndef NO_CUBE_BUILD
/**
* Renders tesseract output into searchable PDF
*/
Expand Down Expand Up @@ -197,6 +198,7 @@ class TESS_API TessPDFRenderer : public TessResultRenderer {
static bool imageToPDFObj(Pix *pix, char *filename, long int objnum,
char **pdf_object, long int *pdf_object_size);
};
#endif // NO_CUBE_BUILD


/**
Expand Down
2 changes: 2 additions & 0 deletions api/tesseractmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,13 @@ int main(int argc, char **argv) {
api.GetBoolVariable("hocr_font_info", &font_info);
renderers.push_back(new tesseract::TessHOcrRenderer(outputbase, font_info));
}
#ifndef NO_CUBE_BUILD
api.GetBoolVariable("tessedit_create_pdf", &b);
if (b) {
renderers.push_back(new tesseract::TessPDFRenderer(outputbase,
api.GetDatapath()));
}
#endif
api.GetBoolVariable("tessedit_write_unlv", &b);
if (b) renderers.push_back(new tesseract::TessUnlvRenderer(outputbase));
api.GetBoolVariable("tessedit_create_boxfile", &b);
Expand Down
46 changes: 26 additions & 20 deletions ccmain/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ AM_CPPFLAGS += \
-I$(top_srcdir)/viewer \
-I$(top_srcdir)/classify -I$(top_srcdir)/dict \
-I$(top_srcdir)/wordrec -I$(top_srcdir)/cutil \
-I$(top_srcdir)/neural_networks/runtime -I$(top_srcdir)/cube \
-I$(top_srcdir)/textord -I$(top_srcdir)/opencl
if USE_OPENCL
AM_CPPFLAGS += -I$(OPENCL_HDR_PATH)
Expand All @@ -15,43 +14,50 @@ AM_CPPFLAGS += -DTESS_EXPORTS \
endif

include_HEADERS = \
thresholder.h ltrresultiterator.h pageiterator.h resultiterator.h \
osdetect.h
thresholder.h ltrresultiterator.h pageiterator.h resultiterator.h \
osdetect.h
noinst_HEADERS = \
control.h cube_reco_context.h cubeclassifier.h docqual.h \
equationdetect.h fixspace.h mutableiterator.h \
control.h docqual.h equationdetect.h fixspace.h mutableiterator.h \
output.h paragraphs.h paragraphs_internal.h paramsd.h pgedit.h \
reject.h tessbox.h tessedit.h tesseractclass.h \
tesseract_cube_combiner.h tessvars.h werdit.h
reject.h tessbox.h tessedit.h tesseractclass.h tessvars.h werdit.h

if !USING_MULTIPLELIBS
noinst_LTLIBRARIES = libtesseract_main.la
else
lib_LTLIBRARIES = libtesseract_main.la
libtesseract_main_la_LDFLAGS = -version-info $(GENERIC_LIBRARY_VERSION)
libtesseract_main_la_LIBADD = \
../wordrec/libtesseract_wordrec.la \
../textord/libtesseract_textord.la \
../wordrec/libtesseract_wordrec.la \
../textord/libtesseract_textord.la \
../ccutil/libtesseract_ccutil.la \
../ccstruct/libtesseract_ccstruct.la \
../viewer/libtesseract_viewer.la \
../dict/libtesseract_dict.la \
../classify/libtesseract_classify.la \
../cutil/libtesseract_cutil.la \
../cube/libtesseract_cube.la \
../opencl/libtesseract_opencl.la

../ccstruct/libtesseract_ccstruct.la \
../viewer/libtesseract_viewer.la \
../dict/libtesseract_dict.la \
../classify/libtesseract_classify.la \
../cutil/libtesseract_cutil.la \
../opencl/libtesseract_opencl.la
if !NO_CUBE_BUILD
libtesseract_main_la_LIBADD += ../cube/libtesseract_cube.la
endif
endif

libtesseract_main_la_SOURCES = \
adaptions.cpp applybox.cpp \
control.cpp cube_control.cpp cube_reco_context.cpp cubeclassifier.cpp \
adaptions.cpp applybox.cpp control.cpp \
docqual.cpp equationdetect.cpp fixspace.cpp fixxht.cpp \
ltrresultiterator.cpp \
osdetect.cpp output.cpp pageiterator.cpp pagesegmain.cpp \
pagewalk.cpp par_control.cpp paragraphs.cpp paramsd.cpp pgedit.cpp recogtraining.cpp \
reject.cpp resultiterator.cpp superscript.cpp \
tesseract_cube_combiner.cpp \
tessbox.cpp tessedit.cpp tesseractclass.cpp tessvars.cpp \
tfacepp.cpp thresholder.cpp \
werdit.cpp

if !NO_CUBE_BUILD
AM_CPPFLAGS += \
-I$(top_srcdir)/neural_networks/runtime -I$(top_srcdir)/cube
noinst_HEADERS += \
cube_reco_context.h cubeclassifier.h tesseract_cube_combiner.h
libtesseract_main_la_SOURCES += \
cube_control.cpp cube_reco_context.cpp cubeclassifier.cpp \
tesseract_cube_combiner.cpp
endif
14 changes: 7 additions & 7 deletions ccmain/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
*
**********************************************************************/

// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif

#include <string.h>
#include <math.h>
#ifdef __UNIX__
Expand All @@ -42,11 +47,6 @@
#include "sorthelper.h"
#include "tesseractclass.h"

// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif

#define MIN_FONT_ROW_COUNT 8
#define MAX_XHEIGHT_DIFF 3

Expand Down Expand Up @@ -393,7 +393,7 @@ bool Tesseract::recog_all_words(PAGE_RES* page_res,
// ****************** Pass 5,6 *******************
rejection_passes(page_res, monitor, target_word_box, word_config);

#ifndef ANDROID_BUILD
#ifndef NO_CUBE_BUILD
// ****************** Pass 7 *******************
// Cube combiner.
// If cube is loaded and its combiner is present, run it.
Expand Down Expand Up @@ -1348,7 +1348,7 @@ 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 ANDROID_BUILD
#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);
Expand Down
2 changes: 1 addition & 1 deletion ccmain/paramsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define VARABLED_H

#include "elst.h"
#ifndef ANDROID_BUILD
#ifndef NO_CUBE_BUILD
#include "scrollview.h"
#endif
#include "params.h"
Expand Down
7 changes: 6 additions & 1 deletion ccmain/tessedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
*
**********************************************************************/

// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif

#include "stderr.h"
#include "basedir.h"
#include "tessvars.h"
Expand Down Expand Up @@ -200,7 +205,7 @@ bool Tesseract::init_tesseract_lang_data(
// engine-specific data files need to be loaded. Currently everything needs
// the base tesseract data, which supplies other useful information, but
// alternative engines, such as cube and LSTM are optional.
#ifndef ANDROID_BUILD
#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)
Expand Down
Loading

0 comments on commit 41478fd

Please sign in to comment.