Disable more code with GRAPHICS_DISABLED

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2021-04-02 16:43:00 +02:00
parent 7a73875bd1
commit 0611c892b6
13 changed files with 53 additions and 25 deletions

View File

@ -13,7 +13,10 @@ SUBDIRS = . tessdata
EXTRA_DIST = README.md LICENSE
EXTRA_DIST += aclocal.m4 config configure.ac autogen.sh
EXTRA_DIST += tesseract.pc.in java doc
EXTRA_DIST += tesseract.pc.in doc
if !GRAPHICS_DISABLED
EXTRA_DIST += java
endif
EXTRA_DIST += CMakeLists.txt tesseract.pc.cmake cmake VERSION
DIST_SUBDIRS = $(SUBDIRS)
@ -30,11 +33,13 @@ dist-hook:
rm -f `find $(distdir) -name '*~'`
rm -rf $(distdir)/doc/html/* $(distdir)/doc/*.log
if !GRAPHICS_DISABLED
ScrollView.jar:
@cd "$(top_builddir)/java" && $(MAKE) $@
install-jars:
@cd "$(top_builddir)/java" && $(MAKE) $@
endif
doc:
-srcdir="$(top_srcdir)" builddir="$(top_builddir)" \
@ -210,8 +215,10 @@ libtesseract_la_SOURCES += src/ccmain/pageiterator.cpp
libtesseract_la_SOURCES += src/ccmain/pagesegmain.cpp
libtesseract_la_SOURCES += src/ccmain/pagewalk.cpp
libtesseract_la_SOURCES += src/ccmain/paragraphs.cpp
if !GRAPHICS_DISABLED
libtesseract_la_SOURCES += src/ccmain/paramsd.cpp
libtesseract_la_SOURCES += src/ccmain/pgedit.cpp
endif
libtesseract_la_SOURCES += src/ccmain/reject.cpp
libtesseract_la_SOURCES += src/ccmain/resultiterator.cpp
libtesseract_la_SOURCES += src/ccmain/tessedit.cpp
@ -648,6 +655,7 @@ endif
# Rules for src/viewer.
if !GRAPHICS_DISABLED
noinst_HEADERS += src/viewer/scrollview.h
noinst_HEADERS += src/viewer/svmnode.h
noinst_HEADERS += src/viewer/svutil.h
@ -655,6 +663,7 @@ noinst_HEADERS += src/viewer/svutil.h
libtesseract_la_SOURCES += src/viewer/scrollview.cpp
libtesseract_la_SOURCES += src/viewer/svmnode.cpp
libtesseract_la_SOURCES += src/viewer/svutil.cpp
endif
# TODO: Add rule to generate svpaint from svpaint.cpp.
@ -692,7 +701,9 @@ libtesseract_la_SOURCES += src/wordrec/lm_state.cpp
libtesseract_la_SOURCES += src/wordrec/outlines.cpp
libtesseract_la_SOURCES += src/wordrec/params_model.cpp
libtesseract_la_SOURCES += src/wordrec/pieces.cpp
if !GRAPHICS_DISABLED
libtesseract_la_SOURCES += src/wordrec/plotedges.cpp
endif
libtesseract_la_SOURCES += src/wordrec/render.cpp
libtesseract_la_SOURCES += src/wordrec/segsearch.cpp
libtesseract_la_SOURCES += src/wordrec/wordclass.cpp

View File

@ -151,9 +151,11 @@ Classify::Classify()
Classify::~Classify() {
EndAdaptiveClassifier();
#ifndef GRAPHICS_DISABLED
delete learn_debug_win_;
delete learn_fragmented_word_debug_win_;
delete learn_fragments_debug_win_;
#endif
}
// Takes ownership of the given classifier, and uses it for future calls

View File

@ -273,7 +273,9 @@ public:
return AdaptedTemplates->NumPermClasses == 0;
}
bool LooksLikeGarbage(TBLOB *blob);
#ifndef GRAPHICS_DISABLED
void RefreshDebugWindow(ScrollView **win, const char *msg, int y_offset, const TBOX &wbox);
#endif
// intfx.cpp
// Computes the DENORMS for bl(baseline) and cn(character) normalization
// during feature extraction. The input denorm describes the current state
@ -471,9 +473,11 @@ protected:
private:
// The currently active static classifier.
ShapeClassifier *static_classifier_ = nullptr;
#ifndef GRAPHICS_DISABLED
ScrollView *learn_debug_win_ = nullptr;
ScrollView *learn_fragmented_word_debug_win_ = nullptr;
ScrollView *learn_fragments_debug_win_ = nullptr;
#endif
// Training data gathered here for all the images in a document.
std::string tr_file_data_;

View File

@ -33,7 +33,9 @@
#include "picofeat.h"
#include "points.h"
#include "shapetable.h"
#ifndef GRAPHICS_DISABLED
#include "svmnode.h"
#endif
#include "helpers.h"

View File

@ -27,7 +27,9 @@
#include "scrollview.h"
#include "shapetable.h"
#ifndef GRAPHICS_DISABLED
#include "svmnode.h"
#endif
#include "tprintf.h"
#include "trainingsample.h"

View File

@ -95,7 +95,6 @@ ColumnFinder::ColumnFinder(int gridsize, const ICOORD &bleft, const ICOORD &trig
, nontext_map_(nullptr)
, projection_(resolution)
, denorm_(nullptr)
, input_blobs_win_(nullptr)
, equation_detect_(nullptr) {
TabVector_IT h_it(&horizontal_lines_);
h_it.add_list_after(hlines);
@ -107,7 +106,9 @@ ColumnFinder::~ColumnFinder() {
}
delete[] best_columns_;
delete stroke_width_;
#ifndef GRAPHICS_DISABLED
delete input_blobs_win_;
#endif
nontext_map_.destroy();
while (denorm_ != nullptr) {
DENORM *dead_denorm = denorm_;

View File

@ -337,17 +337,19 @@ private:
// coordinate space. The destructor must delete all the DENORMs in the chain.
DENORM *denorm_;
// Various debug windows that automatically go away on completion.
ScrollView *input_blobs_win_;
// The equation region detector pointer. Note: This pointer is passed in by
// member function SetEquationDetect, and releasing it is NOT owned by this
// class.
EquationDetectBase *equation_detect_;
#ifndef GRAPHICS_DISABLED
// Various debug windows that automatically go away on completion.
ScrollView *input_blobs_win_ = nullptr;
// Allow a subsequent instance to reuse the blocks window.
// Not thread-safe, but multiple threads shouldn't be using windows anyway.
static ScrollView *blocks_win_;
#endif
};
} // namespace tesseract.

View File

@ -118,20 +118,12 @@ StrokeWidth::StrokeWidth(int gridsize, const ICOORD &bleft, const ICOORD &tright
, denorm_(nullptr)
, grid_box_(bleft, tright)
, rerotation_(1.0f, 0.0f) {
leaders_win_ = nullptr;
widths_win_ = nullptr;
initial_widths_win_ = nullptr;
chains_win_ = nullptr;
diacritics_win_ = nullptr;
textlines_win_ = nullptr;
smoothed_win_ = nullptr;
}
StrokeWidth::~StrokeWidth() {
if (widths_win_ != nullptr) {
#ifndef GRAPHICS_DISABLED
if (widths_win_ != nullptr) {
delete widths_win_->AwaitEvent(SVET_DESTROY);
#endif // !GRAPHICS_DISABLED
if (textord_tabfind_only_strokewidths) {
exit(0);
}
@ -143,6 +135,7 @@ StrokeWidth::~StrokeWidth() {
delete textlines_win_;
delete smoothed_win_;
delete diacritics_win_;
#endif
}
// Sets the neighbours member of the medium-sized blobs in the block.

View File

@ -2,7 +2,6 @@
// File: strokewidth.h
// Description: Subclass of BBGrid to find uniformity of strokewidth.
// Author: Ray Smith
// Created: Mon Mar 31 16:17:01 PST 2008
//
// (C) Copyright 2008, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
@ -297,12 +296,14 @@ private:
// Returns true if there is no significant noise in between the boxes.
bool NoNoiseInBetween(const TBOX &box1, const TBOX &box2) const;
#ifndef GRAPHICS_DISABLED
// Displays the blobs colored according to the number of good neighbours
// and the vertical/horizontal flow.
ScrollView *DisplayGoodBlobs(const char *window_name, int x, int y);
// Displays blobs colored according to whether or not they are diacritics.
ScrollView *DisplayDiacritics(const char *window_name, int x, int y, TO_BLOCK *block);
#endif
private:
// Image map of photo/noise areas on the page. Borrowed pointer (not owned.)
@ -315,14 +316,16 @@ private:
TBOX grid_box_;
// Rerotation to get back to the original image.
FCOORD rerotation_;
#ifndef GRAPHICS_DISABLED
// Windows for debug display.
ScrollView *leaders_win_;
ScrollView *initial_widths_win_;
ScrollView *widths_win_;
ScrollView *chains_win_;
ScrollView *diacritics_win_;
ScrollView *textlines_win_;
ScrollView *smoothed_win_;
ScrollView *leaders_win_ = nullptr;
ScrollView *initial_widths_win_ = nullptr;
ScrollView *widths_win_ = nullptr;
ScrollView *chains_win_ = nullptr;
ScrollView *diacritics_win_ = nullptr;
ScrollView *textlines_win_ = nullptr;
ScrollView *smoothed_win_ = nullptr;
#endif
};
} // namespace tesseract.

View File

@ -32,7 +32,9 @@
#include "sampleiterator.h"
#include "shapeclassifier.h"
#include "shapetable.h"
#ifndef GRAPHICS_DISABLED
#include "svmnode.h"
#endif
#include "scanutils.h"

View File

@ -84,10 +84,12 @@ LSTMTrainer::LSTMTrainer(const char *model_base, const char *checkpoint_name, in
}
LSTMTrainer::~LSTMTrainer() {
#ifndef GRAPHICS_DISABLED
delete align_win_;
delete target_win_;
delete ctc_win_;
delete recon_win_;
#endif
}
// Tries to deserialize a trainer from the given file and silently returns
@ -1077,10 +1079,12 @@ void LSTMTrainer::SetNullChar() {
// Factored sub-constructor sets up reasonable default values.
void LSTMTrainer::EmptyConstructor() {
#ifndef GRAPHICS_DISABLED
align_win_ = nullptr;
target_win_ = nullptr;
ctc_win_ = nullptr;
recon_win_ = nullptr;
#endif
checkpoint_iteration_ = 0;
training_stage_ = 0;
num_training_stages_ = 2;

View File

@ -381,6 +381,7 @@ protected:
TestCallback tester);
protected:
#ifndef GRAPHICS_DISABLED
// Alignment display window.
ScrollView *align_win_;
// CTC target display window.
@ -389,6 +390,7 @@ protected:
ScrollView *ctc_win_;
// Reconstructed image window.
ScrollView *recon_win_;
#endif
// How often to display a debug image.
int debug_interval_;
// Iteration at which the last checkpoint was dumped.

View File

@ -30,14 +30,14 @@
# include "config_auto.h"
#endif
#ifndef GRAPHICS_DISABLED
#include "svmnode.h"
#include <cstring>
#include <iostream>
#ifndef GRAPHICS_DISABLED
# include "scrollview.h"
#include "scrollview.h"
namespace tesseract {