提交 49c4ce31 编写于 作者: Z zdenop@gmail.com

fix for GRAPHICS_DISABLED build

git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@686 d0cd1f9f-072b-0410-8dd7-cf729c803f20
上级 06b2156a
......@@ -622,7 +622,9 @@ int TessBaseAPI::Recognize(ETEXT_DESC* monitor) {
int result = 0;
if (tesseract_->interactive_display_mode) {
#ifndef GRAPHICS_DISABLED
tesseract_->pgeditor_main(rect_width_, rect_height_, page_res_);
#endif // GRAPHICS_DISABLED
// The page_res is invalid after an interactive session, so cleanup
// in a way that lets us continue to the next page without crashing.
delete page_res_;
......
......@@ -705,7 +705,9 @@ void show_point(PAGE_RES* page_res, float x, float y) {
* Blank display of word then redisplay word according to current display mode
* settings
*/
#endif // GRAPHICS_DISABLED
namespace tesseract {
#ifndef GRAPHICS_DISABLED
BOOL8 Tesseract:: word_blank_and_set_display(BLOCK* block, ROW* row,
WERD_RES* word_res) {
word_res->word->bounding_box().plot(image_win, ScrollView::BLACK,
......@@ -896,6 +898,7 @@ BOOL8 Tesseract::word_display(BLOCK* block, ROW* row, WERD_RES* word_res) {
editor_image_word_bb_color));
return TRUE;
}
#endif // GRAPHICS_DISABLED
/**
* word_dumper()
......@@ -919,7 +922,7 @@ BOOL8 Tesseract::word_dumper(BLOCK* block, ROW* row, WERD_RES* word_res) {
return TRUE;
}
#ifndef GRAPHICS_DISABLED
/**
* word_set_display() Word processor
*
......@@ -936,7 +939,9 @@ BOOL8 Tesseract::word_set_display(BLOCK* block, ROW* row, WERD_RES* word_res) {
word->set_display_flag(DF_BLAMER, word_display_mode.bit(DF_BLAMER));
return word_display(block, row, word_res);
}
#endif // GRAPHICS_DISABLED
} // namespace tesseract
#endif // GRAPHICS_DISABLED
......@@ -31,6 +31,11 @@
#include "textord.h"
#include "wordrec.h"
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
class PAGE_RES;
class PAGE_RES_IT;
class BLOCK_LIST;
......@@ -408,7 +413,9 @@ class Tesseract : public Wordrec {
//// pgedit.h //////////////////////////////////////////////////////////
SVMenuNode *build_menu_new();
#ifndef GRAPHICS_DISABLED
void pgeditor_main(int width, int height, PAGE_RES* page_res);
#endif // GRAPHICS_DISABLED
void process_image_event( // action in image win
const SVEvent &event);
BOOL8 process_cmd_win_event( // UI command semantics
......@@ -424,7 +431,9 @@ class Tesseract : public Wordrec {
BOOL8 word_bln_display(BLOCK* block, ROW* row, WERD_RES* word_res);
BOOL8 word_blank_and_set_display(BLOCK* block, ROW* row, WERD_RES* word_res);
BOOL8 word_set_display(BLOCK* block, ROW* row, WERD_RES* word_res);
//#ifndef GRAPHICS_DISABLED
BOOL8 word_dumper(BLOCK* block, ROW* row, WERD_RES* word_res);
//#endif // GRAPHICS_DISABLED
//// reject.h //////////////////////////////////////////////////////////
void make_reject_map( //make rej map for wd //detailed results
WERD_RES *word,
......
......@@ -221,6 +221,7 @@ TBOX TESSLINE::bounding_box() const {
void TESSLINE::plot(ScrollView* window, ScrollView::Color color,
ScrollView::Color child_color) {
#ifndef GRAPHICS_DISABLED
if (is_hole)
window->Pen(child_color);
else
......@@ -235,6 +236,7 @@ void TESSLINE::plot(ScrollView* window, ScrollView::Color color,
else
window->DrawTo(pt->pos.x, pt->pos.y);
} while (pt != loop);
#endif // GRAPHICS_DISABLED
}
// Iterate the given list of outlines, converting to TESSLINE by polygonal
......
......@@ -108,6 +108,7 @@ class STATS {
// Prints summary stats only of the histogram.
void print_summary() const;
#ifndef GRAPHICS_DISABLED
// Draws the histogram as a series of rectangles.
void plot(ScrollView* window, // window to draw in
float xorigin, // origin of histo
......@@ -123,6 +124,8 @@ class STATS {
float xscale, // size of one unit
float yscale, // size of one uint
ScrollView::Color colour) const; // colour to draw in
#endif // GRAPHICS_DISABLED
private:
inT32 rangemin_; // min of range
// rangemax_ is not well named as it is really one past the max.
......
......@@ -23,11 +23,6 @@
#include "linlsq.h"
#include "werd.h"
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#define FIRST_COLOUR ScrollView::RED //< first rainbow colour
#define LAST_COLOUR ScrollView::AQUAMARINE //< last rainbow colour
#define CHILD_COLOUR ScrollView::BROWN //< colour of children
......@@ -291,10 +286,7 @@ void WERD::plot(ScrollView *window, ScrollView::Color colour) {
}
plot_rej_blobs(window);
}
#endif
#ifndef GRAPHICS_DISABLED
#endif // GRAPHICS_DISABLED
// Get the next color in the (looping) rainbow.
ScrollView::Color WERD::NextColor(ScrollView::Color colour) {
......@@ -304,6 +296,7 @@ ScrollView::Color WERD::NextColor(ScrollView::Color colour) {
return next;
}
#ifndef GRAPHICS_DISABLED
/**
* WERD::plot
*
......@@ -319,7 +312,6 @@ void WERD::plot(ScrollView* window) {
}
plot_rej_blobs(window);
}
#endif
/**
......@@ -328,14 +320,14 @@ void WERD::plot(ScrollView* window) {
* Draw the WERD rejected blobs in window - ALWAYS GREY
*/
#ifndef GRAPHICS_DISABLED
void WERD::plot_rej_blobs(ScrollView *window) {
C_BLOB_IT it = &rej_cblobs;
for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
it.data()->plot(window, ScrollView::GREY, ScrollView::GREY);
}
}
#endif
#endif // GRAPHICS_DISABLED
/**
......
......@@ -27,6 +27,11 @@
#include "blckerr.h"
#include "stepblob.h"
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
enum WERD_FLAGS
{
W_SEGMENTED, //< correctly segmented
......@@ -141,17 +146,21 @@ class WERD : public ELIST2_LINK {
// tprintf word metadata (but not blob innards)
void print();
#ifndef GRAPHICS_DISABLED
// plot word on window in a uniform colour
void plot(ScrollView *window, ScrollView::Color colour);
#endif // GRAPHICS_DISABLED
// Get the next color in the (looping) rainbow.
static ScrollView::Color NextColor(ScrollView::Color colour);
#ifndef GRAPHICS_DISABLED
// plot word on window in a rainbow of colours
void plot(ScrollView *window);
// plot rejected blobs in a rainbow of colours
void plot_rej_blobs(ScrollView *window);
#endif // GRAPHICS_DISABLED
private:
uinT8 blanks; // no of blanks
......
......@@ -19,6 +19,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifdef EMBEDDED
#include <ctype.h>
#include <stdarg.h>
#include <stddef.h>
......
......@@ -228,6 +228,7 @@ void Classify::AdaptiveClassifier(TBLOB *Blob,
// Clears the window and draws baselines.
void Classify::RefreshDebugWindow(ScrollView **win, const char *msg,
int y_offset, const TBOX &wbox) {
#ifndef GRAPHICS_DISABLED
const int kSampleSpaceWidth = 500;
if (*win == NULL) {
*win = new ScrollView(msg, 100, y_offset, kSampleSpaceWidth * 2, 200,
......@@ -241,6 +242,7 @@ void Classify::RefreshDebugWindow(ScrollView **win, const char *msg,
kSampleSpaceWidth, kBlnXHeight + kBlnBaselineOffset);
(*win)->ZoomToRectangle(wbox.left(), wbox.top(),
wbox.right(), wbox.bottom());
#endif // GRAPHICS_DISABLED
}
// Learns the given word using its chopped_word, seam_array, denorm,
......@@ -276,6 +278,7 @@ void Classify::LearnWord(const char* filename, const char *rejmap,
int start_blob = 0;
char prev_map_char = '0';
#ifndef GRAPHICS_DISABLED
if (classify_debug_character_fragments) {
if (learn_fragmented_word_debug_win_ != NULL) {
window_wait(learn_fragmented_word_debug_win_);
......@@ -287,6 +290,7 @@ void Classify::LearnWord(const char* filename, const char *rejmap,
word->chopped_word->plot(learn_fragmented_word_debug_win_);
ScrollView::Update();
}
#endif // GRAPHICS_DISABLED
for (int ch = 0; ch < word_len; ++ch) {
if (classify_debug_character_fragments) {
......@@ -410,6 +414,7 @@ void Classify::LearnPieces(const char* filename, int start, int length,
if (rotated_blob == NULL)
rotated_blob = blob;
#ifndef GRAPHICS_DISABLED
// Draw debug windows showing the blob that is being learned if needed.
if (strcmp(classify_learn_debug_str.string(), correct_text) == 0) {
RefreshDebugWindow(&learn_debug_win_, "LearnPieces", 600,
......@@ -424,6 +429,7 @@ void Classify::LearnPieces(const char* filename, int start, int length,
ScrollView::BLUE, ScrollView::BROWN);
learn_fragments_debug_win_->Update();
}
#endif // GRAPHICS_DISABLED
if (filename != NULL) {
classify_norm_method.set_value(character); // force char norm spc 30/11/93
......
......@@ -168,7 +168,7 @@ void RenderIntProto(ScrollView *window,
INT_CLASS Class,
PROTO_ID ProtoId,
ScrollView::Color color);
#endif
#endif // GRAPHICS_DISABLED
int TruncateParam(FLOAT32 Param, int Min, int Max, char *Id);
......@@ -1942,7 +1942,7 @@ int TruncateParam(FLOAT32 Param, int Min, int Max, char *Id) {
/*---------------------------------------------------------------------------*/
#ifndef GRAPHICS_DISABLED
/**
* Initializes the int matcher window if it is not already
* initialized.
......@@ -1991,3 +1991,4 @@ void InitFeatureDisplayWindowIfReqd() {
ScrollView* CreateFeatureSpaceWindow(const char* name, int xpos, int ypos) {
return new ScrollView(name, xpos, ypos, 520, 520, 260, 260, true);
}
#endif // GRAPHICS_DISABLED
......@@ -239,6 +239,7 @@ void ClearFeatureSpaceWindow(NORM_METHOD norm_method, ScrollView* window);
} // namespace tesseract.
/*----------------------------------------------------------------------------*/
#ifndef GRAPHICS_DISABLED
void RenderIntFeature(ScrollView *window, const INT_FEATURE_STRUCT* Feature,
ScrollView::Color color);
......@@ -251,5 +252,6 @@ void InitFeatureDisplayWindowIfReqd();
// Creates a window of the appropriate size for displaying elements
// in feature space.
ScrollView* CreateFeatureSpaceWindow(const char* name, int xpos, int ypos);
#endif // GRAPHICS_DISABLED
#endif
......@@ -681,6 +681,7 @@ void MasterTrainer::DebugCanonical(const char* unichar_str1,
}
}
#ifndef GRAPHICS_DISABLED
// Debugging for cloud/canonical features.
// Displays a Features window containing:
// If unichar_str2 is in the unicharset, and canonical_font is non-negative,
......@@ -742,6 +743,7 @@ void MasterTrainer::DisplaySamples(const char* unichar_str1, int cloud_font,
delete ev;
} while (ev_type != SVET_DESTROY);
}
#endif // GRAPHICS_DISABLED
// Tests the given test_classifier on the internal samples.
// See TestClassifier for details.
......
......@@ -192,6 +192,7 @@ class MasterTrainer {
// Generates debug output relating to the canonical distance between the
// two given UTF8 grapheme strings.
void DebugCanonical(const char* unichar_str1, const char* unichar_str2);
#ifndef GRAPHICS_DISABLED
// Debugging for cloud/canonical features.
// Displays a Features window containing:
// If unichar_str2 is in the unicharset, and canonical_font is non-negative,
......@@ -204,6 +205,7 @@ class MasterTrainer {
// will display the samples that have that feature in a separate window.
void DisplaySamples(const char* unichar_str1, int cloud_font,
const char* unichar_str2, int canonical_font);
#endif // GRAPHICS_DISABLED
// Tests the given test_classifier on the internal samples.
// See TestClassifier for details.
......
......@@ -282,9 +282,11 @@ Pix* TrainingSample::RenderToPix(const UNICHARSET* unicharset) const {
// Displays the features in the given window with the given color.
void TrainingSample::DisplayFeatures(ScrollView::Color color,
ScrollView* window) const {
#ifndef GRAPHICS_DISABLED
for (int f = 0; f < num_features_; ++f) {
RenderIntFeature(window, &features_[f], color);
}
#endif // GRAPHICS_DISABLED
}
// Returns a pix of the original sample image. The pix is padded all round
......
......@@ -75,12 +75,27 @@ AC_ARG_WITH(extra-libraries,
AC_MSG_CHECKING(--enable-graphics argument)
AC_ARG_ENABLE([graphics],
[ --enable-graphics Enable graphics (ScrollView) (default).],
[AC_HELP_STRING([--enable-graphics],[enable graphics (ScrollView) (default)])
AC_HELP_STRING([--disable-graphics],[disable graphics (ScrollView)])],
[enable_graphics=$enableval],
[enable_graphics="yes"])
AC_MSG_RESULT($enable_graphics)
if test "$enable_graphics" = "no"; then
AC_DEFINE([DISABLE_GRAPHICS], [], [Disable graphics])
AC_DEFINE([GRAPHICS_DISABLED], [], [Disable graphics])
fi
# check whether to build embedded version
AC_MSG_CHECKING(--enable-embedded argument)
AC_ARG_ENABLE([embedded],
[ --enable-embedded enable embedded build (default=no)],
[enable_embedded=$enableval],
[enable_embedded="no"])
AC_MSG_RESULT($enable_embedded)
AM_CONDITIONAL([EMBEDDED], [test "$enable_embedded" = "yes"])
if test "$enable_embedded" = "yes"; then
#AC_DEFINE([EMBEDDED], [], [Embedded Mode])
AC_SUBST([AM_CXXFLAGS], [-DEMBEDDED])
AC_SUBST([AM_CPPFLAGS], [-DEMBEDDED])
fi
# check whether to build embedded version
......@@ -100,7 +115,7 @@ fi
# check whether to build multiple libraries
AC_MSG_CHECKING(--enable-multiple-libraries argument)
AC_ARG_ENABLE([multiple-libraries],
[ --enable-multiple-libraries Enable multiple libraries.],
[AC_HELP_STRING([--enable-multiple-libraries],[enable multiple libraries (default=no)])],
[enable_mlibs=$enableval],
[enable_mlibs="no"])
AC_MSG_RESULT($enable_mlibs)
......
......@@ -6,6 +6,7 @@
#include "config_auto.h"
#endif
#ifndef GRAPHICS_DISABLED
#include "allheaders.h"
#include "svshowim.h"
......@@ -36,3 +37,6 @@ void sv_show_sub_image(IMAGE* source, // Image to show.
window->Image(pix, xpos, window->TranslateYCoordinate(yext) + ypos);
pixDestroy(&pix);
}
#endif // GRAPHICS_DISABLED
......@@ -130,9 +130,13 @@ Pix* CCNonTextDetect::ComputeNonTextMask(bool debug, Pix* photo_map,
MarkAndDeleteNonTextBlobs(&blob_block->blobs, -1,
win, ScrollView::WHITE, pix);
if (debug) {
#ifndef GRAPHICS_DISABLED
win->Update();
#endif // GRAPHICS_DISABLED
pixWrite("junkccphotomask.png", pix, IFF_PNG);
#ifndef GRAPHICS_DISABLED
delete win->AwaitEvent(SVET_DESTROY);
#endif // GRAPHICS_DISABLED
delete win;
}
return pix;
......@@ -250,8 +254,10 @@ void CCNonTextDetect::MarkAndDeleteNonTextBlobs(BLOBNBOX_LIST* blobs,
(max_blob_overlaps < 0 ||
!BlobOverlapsTooMuch(blob, max_blob_overlaps))) {
blob->ClearNeighbours();
if (win != NULL)
#ifndef GRAPHICS_DISABLED
if (win != NULL)
blob->plot(win, ok_color, ok_color);
#endif // GRAPHICS_DISABLED
} else {
if (noise_density_->AnyZeroInRect(box)) {
// There is a danger that the bounding box may overlap real text, so
......@@ -272,8 +278,10 @@ void CCNonTextDetect::MarkAndDeleteNonTextBlobs(BLOBNBOX_LIST* blobs,
pixRasterop(nontext_mask, box.left(), imageheight - box.top(),
box.width(), box.height(), PIX_SET, NULL, 0, 0);
}
#ifndef GRAPHICS_DISABLED
if (win != NULL)
blob->plot(win, ScrollView::RED, ScrollView::RED);
#endif // GRAPHICS_DISABLED
// It is safe to delete the cblob now, as it isn't used by the grid
// or BlobOverlapsTooMuch, and the BLOBNBOXes will go away with the
// dead_blobs list.
......
......@@ -155,10 +155,12 @@ void ColumnFinder::SetupAndFilterNoise(Pix* photo_mask_pix,
stroke_width_ = new StrokeWidth(gridsize(), bleft(), tright());
min_gutter_width_ = static_cast<int>(kMinGutterWidthGrid * gridsize());
input_block->ReSetAndReFilterBlobs();
#ifndef GRAPHICS_DISABLED
if (textord_tabfind_show_blocks) {
input_blobs_win_ = MakeWindow(0, 0, "Filtered Input Blobs");
input_block->plot_graded_blobs(input_blobs_win_);
}
#endif // GRAPHICS_DISABLED
SetBlockRuleEdges(input_block);
pixDestroy(&nontext_map_);
// Run a preliminary strokewidth neighbour detection on the medium blobs.
......@@ -358,10 +360,12 @@ int ColumnFinder::FindBlocks(bool single_column,
// Refill the grid using rectangular spreading, and get the benefit
// of the completed tab vectors marking the rule edges of each blob.
Clear();
#ifndef GRAPHICS_DISABLED
if (textord_tabfind_show_reject_blobs) {
ScrollView* rej_win = MakeWindow(500, 300, "Rejected blobs");
input_block->plot_graded_blobs(rej_win);
}
#endif // GRAPHICS_DISABLED
InsertBlobsToGrid(false, false, &image_bblobs_, this);
InsertBlobsToGrid(true, true, &input_block->blobs, this);
......@@ -412,6 +416,7 @@ int ColumnFinder::FindBlocks(bool single_column,
part_grid_.RefinePartitionPartners(true);
SmoothPartnerRuns();
#ifndef GRAPHICS_DISABLED
if (textord_tabfind_show_partitions) {
ScrollView* window = MakeWindow(400, 300, "Partitions");
if (textord_debug_images)
......@@ -424,6 +429,7 @@ int ColumnFinder::FindBlocks(bool single_column,
delete window->AwaitEvent(SVET_DESTROY);
}
}
#endif // GRAPHICS_DISABLED
part_grid_.AssertNoDuplicates();
// Ownership of the ColPartitions moves from part_sets_ to part_grid_ here,
// and ownership of the BLOBNBOXes moves to the ColPartitions.
......@@ -442,6 +448,7 @@ int ColumnFinder::FindBlocks(bool single_column,
DisplayBlocks(blocks);
RotateAndReskewBlocks(input_is_rtl, to_blocks);
int result = 0;
#ifndef GRAPHICS_DISABLED
if (blocks_win_ != NULL) {
bool waiting = false;
do {
......@@ -460,6 +467,7 @@ int ColumnFinder::FindBlocks(bool single_column,
delete event;
} while (waiting);
}
#endif // GRAPHICS_DISABLED
return result;
}
......
......@@ -1718,6 +1718,7 @@ ColPartition* ColPartition::CopyButDontOwnBlobs() {
return copy;
}
#ifndef GRAPHICS_DISABLED
// Provides a color for BBGrid to draw the rectangle.
// Must be kept in sync with PolyBlockType.
ScrollView::Color ColPartition::BoxColor() const {
......@@ -1725,6 +1726,7 @@ ScrollView::Color ColPartition::BoxColor() const {
return BLOBNBOX::TextlineColor(blob_type_, flow_);
return POLY_BLOCK::ColorForPolyBlockType(type_);
}
#endif // GRAPHICS_DISABLED
// Keep in sync with BlobRegionType.
static char kBlobTypes[BRT_COUNT + 1] = "NHSRIUVT";
......
......@@ -374,12 +374,14 @@ void ColPartitionSet::GetColumnBoxes(int y_bottom, int y_top,
// Display the edges of the columns at the given y coords.
void ColPartitionSet::DisplayColumnEdges(int y_bottom, int y_top,
ScrollView* win) {
#ifndef GRAPHICS_DISABLED
ColPartition_IT it(&parts_);
for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
ColPartition* part = it.data();
win->Line(part->LeftAtY(y_top), y_top, part->LeftAtY(y_bottom), y_bottom);
win->Line(part->RightAtY(y_top), y_top, part->RightAtY(y_bottom), y_bottom);
}
#endif // GRAPHICS_DISABLED
}
// Return the ColumnSpanningType that best explains the columns overlapped
......
......@@ -133,7 +133,9 @@ StrokeWidth::StrokeWidth(int gridsize,
StrokeWidth::~StrokeWidth() {
if (widths_win_ != NULL) {
#ifndef GRAPHICS_DISABLED
delete widths_win_->AwaitEvent(SVET_DESTROY);
#endif // GRAPHICS_DISABLED
if (textord_tabfind_only_strokewidths)
exit(0);
delete widths_win_;
......@@ -322,6 +324,7 @@ void StrokeWidth::RemoveLineResidue(ColPartition_LIST* big_part_list) {
box.print();
}
if (max_size * kLineResidueSizeRatio < box.height()) {
#ifndef GRAPHICS_DISABLED
if (leaders_win_ != NULL) {
// We are debugging, so display deleted in pink blobs in the same
// window that we use to display leader detection.
......@@ -329,6 +332,7 @@ void StrokeWidth::RemoveLineResidue(ColPartition_LIST* big_part_list) {
leaders_win_->Rectangle(box.left(), box.bottom(),
box.right(), box.top());
}
#endif // GRAPHICS_DISABLED
ColPartition::MakeBigPartition(bbox, big_part_list);
}
}
......@@ -547,12 +551,14 @@ void StrokeWidth::MarkLeaderNeighbours(const ColPartition* part,
best_blob->set_leader_on_right(true);
else
best_blob->set_leader_on_left(true);
#ifndef GRAPHICS_DISABLED
if (leaders_win_ != NULL) {
leaders_win_->Pen(side == LR_LEFT ? ScrollView::RED : ScrollView::GREEN);
const TBOX& blob_box = best_blob->bounding_box();
leaders_win_->Rectangle(blob_box.left(), blob_box.bottom(),
blob_box.right(), blob_box.top());
}
#endif // GRAPHICS_DISABLED
}
}
......@@ -1870,7 +1876,9 @@ static void DrawDiacriticJoiner(const BLOBNBOX* blob, ScrollView* window) {
int top = MAX(blob_box.top(), blob->base_char_top());
int bottom = MIN(blob_box.bottom(), blob->base_char_bottom());
int x = (blob_box.left() + blob_box.right()) / 2;
#ifndef GRAPHICS_DISABLED
window->Line(x, top, x, bottom);
#endif // GRAPHICS_DISABLED
}
// Displays blobs colored according to whether or not they are diacritics.
......
......@@ -459,6 +459,7 @@ bool TabFind::FindTabVectors(TabVector_LIST* hlines,
return false; // Skew angle is too large.
part_grid->Deskew(*deskew);
ApplyTabConstraints();
#ifndef GRAPHICS_DISABLED
if (textord_tabfind_show_finaltabs) {
tab_win = MakeWindow(640, 50, "FinalTabs");
if (textord_debug_images) {
......@@ -470,6 +471,7 @@ bool TabFind::FindTabVectors(TabVector_LIST* hlines,
}
tab_win = DisplayTabVectors(tab_win);
}
#endif // GRAPHICS_DISABLED
return true;
}
......@@ -502,10 +504,12 @@ void TabFind::TidyBlobs(TO_BLOCK* block) {
if (textord_debug_tabfind) {
tprintf("Moved %d large blobs to normal list\n",
b_count);
#ifndef GRAPHICS_DISABLED
ScrollView* rej_win = MakeWindow(500, 300, "Image blobs");
block->plot_graded_blobs(rej_win);
block->plot_noise_blobs(rej_win);
rej_win->Update();
#endif // GRAPHICS_DISABLED
}
block->DeleteUnownedNoise();
}
......@@ -561,6 +565,7 @@ ScrollView* TabFind::FindInitialTabVectors(BLOBNBOX_LIST* image_blobs,
// Helper displays all the boxes in the given vector on the given window.
static void DisplayBoxVector(const GenericVector<BLOBNBOX*> boxes,
ScrollView* win) {
#ifndef GRAPHICS_DISABLED
for (int i = 0; i < boxes.size(); ++i) {
TBOX box = boxes[i]->bounding_box();
int left_x = box.left();
......@@ -572,6 +577,7 @@ static void DisplayBoxVector(const GenericVector<BLOBNBOX*> boxes,
win->Rectangle(left_x, bottom_y, right_x, top_y);
}
win->Update();
#endif // GRAPHICS_DISABLED
}
// For each box in the grid, decide whether it is a candidate tab-stop,
......@@ -597,6 +603,7 @@ ScrollView* TabFind::FindTabBoxes(int min_gutter_width) {
left_tab_boxes_.sort(SortByBoxLeft<BLOBNBOX>);
right_tab_boxes_.sort(SortRightToLeft<BLOBNBOX>);
ScrollView* tab_win = NULL;
#ifndef GRAPHICS_DISABLED
if (textord_tabfind_show_initialtabs) {
tab_win = MakeWindow(0, 100, "InitialTabs");
tab_win->Pen(ScrollView::BLUE);
......@@ -606,6 +613,7 @@ ScrollView* TabFind::FindTabBoxes(int min_gutter_width) {
DisplayBoxVector(right_tab_boxes_, tab_win);
tab_win = DisplayTabs("Tabs", tab_win);
}
#endif // GRAPHICS_DISABLED
return tab_win;
}
......@@ -965,6 +973,7 @@ void TabFind::EvaluateTabs() {
// can be tested for being a common width with a simple callback function.
void TabFind::ComputeColumnWidths(ScrollView* tab_win,
ColPartitionGrid* part_grid) {
#ifndef GRAPHICS_DISABLED
if (tab_win != NULL)
tab_win->Pen(ScrollView::WHITE);
// Accumulate column sections into a STATS
......@@ -977,7 +986,7 @@ void TabFind::ComputeColumnWidths(ScrollView* tab_win,
if (textord_debug_tabfind > 1)
col_widths.print();
// Now make a list of column widths.
MakeColumnWidths(col_widths_size, &col_widths);
#endif // GRAPHICS_DISABLED
}
// Find column width and pair-up tab vectors with existing ColPartitions.
......
......@@ -742,6 +742,7 @@ void TableFinder::SetGlobalSpacings(ColPartitionGrid* grid) {
set_global_median_xheight(static_cast<int>(xheight_stats.median() + 0.5));
set_global_median_blob_width(static_cast<int>(width_stats.median() + 0.5));
set_global_median_ledding(static_cast<int>(ledding_stats.median() + 0.5));
#ifndef GRAPHICS_DISABLED
if (textord_tablefind_show_stats) {
const char* kWindowName = "X-height (R), X-width (G), and ledding (B)";
ScrollView* stats_win = MakeWindow(500, 10, kWindowName);
......@@ -749,6 +750,7 @@ void TableFinder::SetGlobalSpacings(ColPartitionGrid* grid) {
width_stats.plot(stats_win, 10, 200, 2, 15, ScrollView::GREEN);
ledding_stats.plot(stats_win, 10, 200, 2, 15, ScrollView::BLUE);
}
#endif // GRAPHICS_DISABLED
}
void TableFinder::set_global_median_xheight(int xheight) {
......
......@@ -77,6 +77,7 @@ void TextlineProjection::ConstructProjection(TO_BLOCK* input_block,
// Display the blobs in the window colored according to textline quality.
void TextlineProjection::PlotGradedBlobs(BLOBNBOX_LIST* blobs,
ScrollView* win) {
#ifndef GRAPHICS_DISABLED
BLOBNBOX_IT it(blobs);
for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
BLOBNBOX* blob = it.data();
......@@ -89,6 +90,7 @@ void TextlineProjection::PlotGradedBlobs(BLOBNBOX_LIST* blobs,
win->Rectangle(box.left(), box.bottom(), box.right(), box.top());
}
win->Update();
#endif // GRAPHICS_DISABLED
}
// Moves blobs that look like they don't sit well on a textline from the
......
......@@ -242,8 +242,11 @@ void Textord::filter_blobs(ICOORD page_tr, // top right
TO_BLOCK_IT block_it = blocks; // destination iterator
TO_BLOCK *block; // created block
#ifndef GRAPHICS_DISABLED
if (to_win != NULL)
to_win->Clear();
#endif // GRAPHICS_DISABLED
for (block_it.mark_cycle_pt(); !block_it.cycled_list();
block_it.forward()) {
block = block_it.data();
......@@ -258,7 +261,8 @@ void Textord::filter_blobs(ICOORD page_tr, // top right
tesseract::CCStruct::kXHeightFraction;
block->line_size *= textord_min_linesize;
block->max_blob_size = block->line_size * textord_excess_blobsize;
#ifndef GRAPHICS_DISABLED
#ifndef GRAPHICS_DISABLED
if (textord_show_blobs && testing_on) {
if (to_win == NULL)
create_to_win(page_tr);
......@@ -272,7 +276,7 @@ void Textord::filter_blobs(ICOORD page_tr, // top right
plot_box_list(to_win, &block->large_blobs, ScrollView::WHITE);
plot_box_list(to_win, &block->blobs, ScrollView::WHITE);
}
#endif
#endif // GRAPHICS_DISABLED
}
}
......
......@@ -86,6 +86,7 @@ int main (
/*----------------------------------------------------------------------------
Public Code
-----------------------------------------------------------------------------*/
#ifndef GRAPHICS_DISABLED
static void DisplayProtoList(const char* ch, LIST protolist) {
void* window = c_create_window("Char samples", 50, 200,
520, 520, -130.0, 130.0, -130.0, 130.0);
......@@ -116,6 +117,7 @@ static void DisplayProtoList(const char* ch, LIST protolist) {
}
c_make_current(window);
}
#endif // GRAPHICS_DISABLED
// Helper to run clustering on a single config.
// Mostly copied from the old mftraining, but with renamed variables.
......@@ -135,8 +137,10 @@ static LIST ClusterOneConfig(int shape_id, const char* class_label,
// Merge protos where reasonable to make more of them significant by
// representing almost all samples of the class/font.
MergeInsignificantProtos(proto_list, class_label, clusterer, &Config);
#ifndef GRAPHICS_DISABLED
if (strcmp(FLAGS_test_ch.c_str(), class_label) == 0)
DisplayProtoList(FLAGS_test_ch.c_str(), proto_list);
#endif // GRAPHICS_DISABLED
// Delete the protos that will not be used in the inttemp output file.
proto_list = RemoveInsignificantProtos(proto_list, true,
false,
......
......@@ -48,10 +48,12 @@ int main(int argc, char **argv) {
argc, argv, false, NULL, &file_prefix);
if (FLAGS_display_cloud_font >= 0) {
#ifndef GRAPHICS_DISABLED
trainer->DisplaySamples(FLAGS_canonical_class1.c_str(),
FLAGS_display_cloud_font,
FLAGS_canonical_class2.c_str(),
FLAGS_display_canonical_font);
#endif // GRAPHICS_DISABLED
return 0;
} else if (!FLAGS_canonical_class1.empty()) {
trainer->DebugCanonical(FLAGS_canonical_class1.c_str(),
......
......@@ -36,6 +36,11 @@
#include <stdio.h>
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
class ScrollView;
class SVNetwork;
class SVMutex;
......
......@@ -11,12 +11,12 @@
// - A LMB click either draws point-to-point, point or text.
// - A LMB dragging either draws a line, a rectangle or ellipse.
#include "scrollview.h"
#include "svmnode.h"
#include <stdlib.h>
#include <iostream>
#ifndef GRAPHICS_DISABLED
// The current color values we use, initially white (== ScrollView::WHITE).
int rgb[3] = { 255, 255, 255 };
......@@ -218,3 +218,4 @@ int main(int argc, char** argv) {
if (argc > 1) { server_name = argv[1]; } else { server_name = "localhost"; }
SVPaint svp(server_name);
}
#endif // GRAPHICS_DISABLED
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册