diff --git a/ccmain/baseapi.cpp b/ccmain/baseapi.cpp index cd927cd2..e43c5d56 100644 --- a/ccmain/baseapi.cpp +++ b/ccmain/baseapi.cpp @@ -470,7 +470,9 @@ PAGE_RES* TessBaseAPI::Recognize(BLOCK_LIST* block_list, ETEXT_DESC* monitor) { PAGE_RES* page_res = new PAGE_RES(block_list); if (interactive_mode) { - pgeditor_main(block_list); //pgeditor user I/F +#ifndef GRAPHICS_DISABLED + pgeditor_main(block_list); // pgeditor user I/F +#endif } else if (tessedit_train_from_boxes) { apply_box_training(block_list); } else { @@ -833,7 +835,11 @@ TBLOB *make_tesseract_blob(float baseline, float xheight, float descender, float page_image.get_ysize()); // Create C_BLOBs from the page - extract_edges(NULL, &page_image, &page_image, + extract_edges( +#ifndef GRAPHICS_DISABLED + NULL, +#endif + &page_image, &page_image, ICOORD(page_image.get_xsize(), page_image.get_ysize()), block); diff --git a/ccmain/pgedit.cpp b/ccmain/pgedit.cpp index 2c7c7332..4dd6f989 100755 --- a/ccmain/pgedit.cpp +++ b/ccmain/pgedit.cpp @@ -38,6 +38,7 @@ #include "control.h" +#ifndef GRAPHICS_DISABLED #define ASC_HEIGHT (2 * bln_baseline_offset + bln_x_height) #define X_HEIGHT (bln_baseline_offset + bln_x_height) #define BL_HEIGHT bln_baseline_offset @@ -87,9 +88,7 @@ enum CMD_EVENTS **********************************************************************/ ScrollView* image_win; -#ifndef GRAPHICS_DISABLED VariablesEditor* ve; -#endif bool stillRunning = false; #ifdef __UNIX__ @@ -660,9 +659,7 @@ void do_write_file( // serialise void PGEventHandler::Notify(const SVEvent* event) { char myval = '0'; if (event->type == SVET_POPUP) { -#ifndef GRAPHICS_DISABLED ve->Notify(event); -#endif } // These are handled by Var. Editor else if (event->type == SVET_EXIT) { stillRunning = false; } else if (event->type == SVET_MENU) { @@ -728,7 +725,7 @@ void pgeditor_msg( // message display image_win->AddMessage(msg); } - +#endif // GRAPHCICS_DISABLED /********************************************************************** * pgeditor_read_file() * @@ -739,6 +736,10 @@ void pgeditor_read_file( // of serialised file STRING &name, BLOCK_LIST *blocks // block list to add to ) { +#ifdef GRAPHICS_DISABLED + edges_and_textord(name.string(), blocks); +} +#else int c; // input character FILE *infp; // input file BLOCK_IT block_it(blocks); // iterator @@ -1856,6 +1857,7 @@ BOOL8 word_toggle_seg( // toggle seg flag return TRUE; } +#endif // GRAPHICS_DISABLED /* DEBUG ONLY */ diff --git a/ccmain/tesseractmain.cpp b/ccmain/tesseractmain.cpp index 5f14e403..fc06b777 100644 --- a/ccmain/tesseractmain.cpp +++ b/ccmain/tesseractmain.cpp @@ -140,7 +140,6 @@ void TesseractImage(const char* input_file, IMAGE* image, STRING* text_out) { * **********************************************************************/ -#ifndef GRAPHICS_DISABLED int main(int argc, char **argv) { STRING outfile; //output file @@ -241,62 +240,6 @@ int main(int argc, char **argv) { return 0; //Normal exit } -#else - -int main(int argc, char **argv) { - uinT16 lang; //language - STRING pagefile; //input file - - if (argc < 4) { - USAGE.error (argv[0], EXIT, - "%s imagename outputbase configfile [[+|-]varfile]...\n", argv[0]); - } - - time_t t_start = time(NULL); - - init_tessembedded (argv[0], argv[2], argv[3], argc - 4, argv + 4); - - tprintf ("Tesseract Open Source OCR Engine (graphics disabled)\n"); - - if (tessedit_read_image) { -#ifdef _TIFFIO_ - TIFF* tif = TIFFOpen(argv[1], "r"); - if (tif) { - read_tiff_image(tif); - TIFFClose(tif); - } else - READFAILED.error (argv[0], EXIT, argv[1]); - -#else - if (page_image.read_header (argv[1]) < 0) - READFAILED.error (argv[0], EXIT, argv[1]); - if (page_image.read (page_image.get_ysize ()) < 0) { - MEMORY_OUT.error (argv[0], EXIT, "Read of image %s", - argv[1]); - } -#endif - } - - pagefile = argv[1]; - - BLOCK_LIST current_block_list; - tessembedded_read_file(pagefile, ¤t_block_list); - tprintf ("Done reading files.\n"); - - PAGE_RES page_res(¤t_block_list); - - recog_all_words(&page_res, NULL); - - current_block_list.clear(); - ResetAdaptiveClassifier(); - - time_t t_end = time(NULL); - double secs = difftime(t_end, t_start); - tprintf ("Done. Number of seconds: %d\n", (int)secs); - return 0; //Normal exit -} - -#endif int initialized = 0; diff --git a/ccmain/tfacep.h b/ccmain/tfacep.h index b6ca149c..01df4710 100644 --- a/ccmain/tfacep.h +++ b/ccmain/tfacep.h @@ -42,7 +42,6 @@ #include "badwords.h" #include "structures.h" -#define BLOB_MATCHING_ON typedef void (*TESS_TESTER) (TBLOB *, BOOL8, char *, inT32, LIST); typedef LIST (*TESS_MATCHER) (TBLOB *, TBLOB *, TBLOB *, void *, TEXTROW *); diff --git a/ccutil/mainblk.cpp b/ccutil/mainblk.cpp index 4e3e3bc9..7371a9f5 100644 --- a/ccutil/mainblk.cpp +++ b/ccutil/mainblk.cpp @@ -17,8 +17,6 @@ * **********************************************************************/ -#define BLOB_MATCHING_ON - #include "mfcpch.h" #include "fileerr.h" #ifdef __UNIX__ diff --git a/ccutil/mainblk.h b/ccutil/mainblk.h index 8c4fe11f..e499e092 100644 --- a/ccutil/mainblk.h +++ b/ccutil/mainblk.h @@ -23,15 +23,6 @@ #include "varable.h" #include "notdll.h" -//#ifndef BLOB_MATCHING_ON -//class BLOB; -//class ROW; -// float compare_blobs(BLOB*,ROW*,BLOB*,ROW*) -//{ -// return (float)MAX_INT32; -//} -//#endif - extern DLLSYM STRING datadir; //dir for data files //name of image extern DLLSYM STRING imagebasename; diff --git a/classify/adaptmatch.cpp b/classify/adaptmatch.cpp index 2f67659e..3e7cfa0c 100644 --- a/classify/adaptmatch.cpp +++ b/classify/adaptmatch.cpp @@ -1186,7 +1186,8 @@ void AdaptToChar(TBLOB *Blob, MakePermanent (AdaptedTemplates, ClassId, NewTempConfigId, Blob, LineStats); - if (LearningDebugLevel >= 1) { +#ifndef GRAPHICS_DISABLED + if (LearningDebugLevel >= 1) { IntegerMatcher (IClass, AllProtosOn, AllConfigsOn, NumFeatures, NumFeatures, IntFeatures, 0, &IntResult, NO_DEBUG); @@ -1203,6 +1204,7 @@ void AdaptToChar(TBLOB *Blob, GetClassToDebug ("Adapting"); } } +#endif // GRAPHICS_DISABLED } FreeFeatureSet(FloatFeatures); } diff --git a/cutil/const.h b/cutil/const.h index defdf5e4..af9f56fa 100644 --- a/cutil/const.h +++ b/cutil/const.h @@ -42,9 +42,6 @@ #define NULL 0 /*null pointer array index */ #endif -#define MAXINT 2147483647 /*max value of an int */ -//#define MAXSHORT 32767 /*max value of short*/ -//#define MAXCHAR 127 /*max value of a char*/ #define MAXUCHAR 255 /*max value of unsigned char */ #define PI 3.14159265359/*pi */ #ifndef __UNIX__ diff --git a/dict/stopper.cpp b/dict/stopper.cpp index 19886a60..fd41b5c4 100644 --- a/dict/stopper.cpp +++ b/dict/stopper.cpp @@ -1188,7 +1188,7 @@ int LengthOfShortestAlphaRun(register char *Word, const char *Word_lengths) { ** Exceptions: none ** History: Tue May 14 07:50:45 1991, DSJ, Created. */ - register int Shortest = MAXINT; + register int Shortest = MAX_INT32; register int Length; for (; *Word; Word += *(Word_lengths++)) @@ -1202,7 +1202,7 @@ int LengthOfShortestAlphaRun(register char *Word, const char *Word_lengths) { if (*Word == 0) break; } - if (Shortest == MAXINT) + if (Shortest == MAX_INT32) Shortest = 0; return (Shortest); diff --git a/makemoredists b/makemoredists index 7d981768..4e0fc972 100755 --- a/makemoredists +++ b/makemoredists @@ -1,5 +1,5 @@ #!/bin/bash -winlist="tessdll.dll tessdll.lib tesseract.exe dlltest.exe training/cnTraining.exe training/mfTraining.exe training/unicharset_extractor.exe training/wordlist2dawg.exe" +winlist="tessdll.dll tessdll.lib tesseract.exe dlltest.exe training/cnTraining.exe training/mfTraining.exe training/unicharset_extractor.exe training/wordlist2dawg.exe java/ScrollView.jar" ver=`ls -1rt *[0-9].tar.gz |tail -1` ver=${ver%.tar.gz} for l in eng deu fra ita spa nld por deu-f vie kan diff --git a/textord/blobcmpl.h b/textord/blobcmpl.h index 05869f03..2ce7350b 100644 --- a/textord/blobcmpl.h +++ b/textord/blobcmpl.h @@ -22,7 +22,6 @@ class PBLOB; class ROW; -#define BLOB_MATCHING_ON float compare_blobs( //match 2 blobs PBLOB *blob1, //first blob diff --git a/textord/drawedg.cpp b/textord/drawedg.cpp index 3335738c..3ca6686f 100644 --- a/textord/drawedg.cpp +++ b/textord/drawedg.cpp @@ -20,6 +20,8 @@ #include "mfcpch.h" #include "drawedg.h" +#ifndef GRAPHICS_DISABLED + #define IMAGE_WIN_NAME "Edges"//title of window #define IMAGE_XPOS 250 #define IMAGE_YPOS 0 //default position @@ -72,3 +74,4 @@ void draw_raw_edge( //draw the cracks while (edgept != start); } +#endif // GRAPHICS_DISABLED diff --git a/textord/drawtord.cpp b/textord/drawtord.cpp index a5e001de..e598373f 100644 --- a/textord/drawtord.cpp +++ b/textord/drawtord.cpp @@ -50,6 +50,7 @@ EXTERN FILE *to_debug = NULL; * * Create the to window used to show the fit. **********************************************************************/ +#ifndef GRAPHICS_DISABLED void create_to_win( //make features win ICOORD page_tr //size of page @@ -87,7 +88,6 @@ void create_todebug_win() { //make gradients win to_debug = fopen (to_debugfile.string (), "w"); } - /********************************************************************** * plot_blob_list * @@ -466,3 +466,4 @@ void plot_row_cells( //draw words win->Line(cell->x () + xshift, word_box.bottom (), cell->x () + xshift, word_box.top ()); } } +#endif // GRAPHICS_DISABLED \ No newline at end of file diff --git a/textord/tordmain.cpp b/textord/tordmain.cpp index 58a3a453..9e19c988 100644 --- a/textord/tordmain.cpp +++ b/textord/tordmain.cpp @@ -42,10 +42,6 @@ const ERRCODE BLOCKLESS_BLOBS = "Warning:some blobs assigned to no block"; -#ifdef GRAPHICS_DISABLED -ETEXT_DESC *global_monitor = NULL; -#endif - #define EXTERN EXTERN BOOL_VAR (textord_no_rejects, FALSE, "Don't remove noise blobs"); diff --git a/training/cntraining.vcproj b/training/cntraining.vcproj index f83af2c0..bc4f0f7f 100755 --- a/training/cntraining.vcproj +++ b/training/cntraining.vcproj @@ -54,7 +54,7 @@ AssemblerListingLocation=".\cntrain.Release/" ObjectFile=".\cntrain.Release/" ProgramDataBaseFileName=".\cntrain.Release/" - BrowseInformation="2" + BrowseInformation="0" BrowseInformationFile=".\cntrain.Release/" WarningLevel="3" SuppressStartupBanner="true" diff --git a/viewer/scrollview.cpp b/viewer/scrollview.cpp index c08cf370..1b14f666 100644 --- a/viewer/scrollview.cpp +++ b/viewer/scrollview.cpp @@ -17,6 +17,8 @@ // /////////////////////////////////////////////////////////////////////// // + +#ifndef GRAPHICS_DISABLED // This class contains the main ScrollView-logic, // e.g. parsing & sending messages, images etc. #ifdef WIN32 @@ -30,7 +32,7 @@ const int kMaxIntPairSize = 45; // Holds %d,%d, for upto 64 bit. #include "scrollview.h" #include -#include +#include #include #include #include @@ -817,3 +819,6 @@ int ScrollView::TranslateYCoordinate(int y) { if (!y_axis_is_reversed_) { return y; } else { return y_size_ - y; } } + + +#endif // GRAPHICS_DISABLED \ No newline at end of file diff --git a/viewer/scrollview.h b/viewer/scrollview.h index cc75e7e2..0d31996d 100644 --- a/viewer/scrollview.h +++ b/viewer/scrollview.h @@ -150,6 +150,8 @@ class ScrollView { GREEN_YELLOW // Make sure this one is last. }; +#ifndef GRAPHICS_DISABLED + // Create a window. The pixel size of the window may be 0,0, in which case // a default size is selected based on the size of your canvas. // The canvas may not be 0,0 in size! @@ -404,6 +406,7 @@ class ScrollView { // Semaphore to the thread belonging to this window. SVSemaphore* semaphore_; +#endif // GRAPHICS_DISABLED }; #endif // THIRD_PARTY_TESSERACT_VIEWER_SCROLLVIEW_H__ diff --git a/viewer/svmnode.cpp b/viewer/svmnode.cpp index 22a7e1d7..0e7dc88d 100644 --- a/viewer/svmnode.cpp +++ b/viewer/svmnode.cpp @@ -26,6 +26,8 @@ // menu bars. #include "svmnode.h" +#ifndef GRAPHICS_DISABLED + #include #include @@ -133,3 +135,5 @@ void SVMenuNode::BuildMenu(ScrollView* sv, bool menu_bar) { if (child_ != NULL) { child_->BuildMenu(sv, menu_bar); delete child_; } if (next_ != NULL) { next_->BuildMenu(sv, menu_bar); delete next_; } } + +#endif // GRAPHICS_DISABLED \ No newline at end of file diff --git a/viewer/svutil.cpp b/viewer/svutil.cpp index d2686307..a0a78d70 100644 --- a/viewer/svutil.cpp +++ b/viewer/svutil.cpp @@ -20,6 +20,8 @@ // SVUtil contains the SVSync and SVNetwork classes, which are used for // thread/process creation & synchronization and network connection. +#ifndef GRAPHICS_DISABLED + #include "svutil.h" #ifdef WIN32 @@ -341,3 +343,5 @@ SVNetwork::~SVNetwork() { delete[] msg_buffer_in_; delete mutex_send_; } + +#endif // GRAPHICS_DISABLED diff --git a/wordrec/drawfx.cpp b/wordrec/drawfx.cpp index 610507bd..049d8ca8 100644 --- a/wordrec/drawfx.cpp +++ b/wordrec/drawfx.cpp @@ -22,6 +22,7 @@ #include "werd.h" #include "drawfx.h" +#ifndef GRAPHICS_DISABLED #define FXDEMOWIN "FXDemo" #define FXDEMOXPOS 250 #define FXDEMOYPOS 0 @@ -73,6 +74,7 @@ void clear_fx_win() { //make features win fx_win->Line(-WERDWIDTH, bln_x_height + bln_baseline_offset, WERDWIDTH, bln_x_height + bln_baseline_offset); } +#endif // GRAPHICS_DISABLED /********************************************************************** * create_fxdebug_win diff --git a/wordrec/metrics.cpp b/wordrec/metrics.cpp index 31835eef..59ec9505 100644 --- a/wordrec/metrics.cpp +++ b/wordrec/metrics.cpp @@ -144,10 +144,10 @@ void end_metrics() { void record_certainty(float certainty, int pass) { int bucket; - if (certainty / CERTAINTY_BUCKET_SIZE < MAXINT) + if (certainty / CERTAINTY_BUCKET_SIZE < MAX_INT32) bucket = (int) (certainty / CERTAINTY_BUCKET_SIZE); else - bucket = MAXINT; + bucket = MAX_INT32; inc_tally_bucket (best_certainties[pass - 1], bucket); } diff --git a/wordrec/olutil.cpp b/wordrec/olutil.cpp index b02dc11f..78cff8d0 100644 --- a/wordrec/olutil.cpp +++ b/wordrec/olutil.cpp @@ -112,10 +112,10 @@ void eliminate_duplicate_outlines(TBLOB *blob) { **********************************************************************/ void setup_outline(TESSLINE *outline) { register EDGEPT *this_edge; - register int minx = MAXINT; - register int miny = MAXINT; - register int maxx = -MAXINT; - register int maxy = -MAXINT; + register int minx = MAX_INT32; + register int miny = MAX_INT32; + register int maxx = -MAX_INT32; + register int maxy = -MAX_INT32; /* Find boundaries */ this_edge = outline->loop; diff --git a/wordrec/plotedges.cpp b/wordrec/plotedges.cpp index 9b659ea2..174069a5 100644 --- a/wordrec/plotedges.cpp +++ b/wordrec/plotedges.cpp @@ -30,6 +30,8 @@ #include "render.h" #include "split.h" +#ifndef GRAPHICS_DISABLED + /*---------------------------------------------------------------------- V a r i a b l e s ----------------------------------------------------------------------*/ @@ -128,3 +130,5 @@ void mark_split(SPLIT *split) { c_draw (window, (float) split->point2->pos.x, (float) split->point2->pos.y); c_make_current(window); } + +#endif // GRAPHICS_DISABLED diff --git a/wordrec/plotseg.cpp b/wordrec/plotseg.cpp index 8876580f..0d009819 100644 --- a/wordrec/plotseg.cpp +++ b/wordrec/plotseg.cpp @@ -34,6 +34,8 @@ #include "const.h" #include +#ifndef GRAPHICS_DISABLED + /*---------------------------------------------------------------------- V a r i a b l e s ----------------------------------------------------------------------*/ @@ -104,9 +106,11 @@ void render_segmentation(ScrollView *window, if (char_num < segmentation[0]) chunks_left = segmentation[char_num + 1]; else - chunks_left = MAXINT; + chunks_left = MAX_INT32; } render_outline(window, blob->outlines, color); } window->ZoomToRectangle(topleft.x, topleft.y, botright.x, botright.y); } + +#endif // GRPAHICS_DISABLED \ No newline at end of file diff --git a/wordrec/render.cpp b/wordrec/render.cpp index d4aac615..a95fdc46 100644 --- a/wordrec/render.cpp +++ b/wordrec/render.cpp @@ -54,6 +54,7 @@ make_toggle_var (blob_pause, 0, make_blob_pause, /*---------------------------------------------------------------------- F u n c t i o n s ----------------------------------------------------------------------*/ +#ifndef GRAPHICS_DISABLED /********************************************************************** * display_blob * @@ -147,3 +148,5 @@ void render_outline(void *window, /* Add on child outlines */ render_outline(window, outline->child, Grey); } + +#endif // GRAPHICS_DISABLED