Skip to content

Commit

Permalink
Fixed compilation with GRAPHICS_DISABLED
Browse files Browse the repository at this point in the history
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@250 d0cd1f9f-072b-0410-8dd7-cf729c803f20
  • Loading branch information
theraysmith committed Jun 3, 2009
1 parent c2ca19e commit bea5e04
Show file tree
Hide file tree
Showing 25 changed files with 64 additions and 98 deletions.
10 changes: 8 additions & 2 deletions ccmain/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);

Expand Down
12 changes: 7 additions & 5 deletions ccmain/pgedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -87,9 +88,7 @@ enum CMD_EVENTS
**********************************************************************/

ScrollView* image_win;
#ifndef GRAPHICS_DISABLED
VariablesEditor* ve;
#endif
bool stillRunning = false;

#ifdef __UNIX__
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -728,7 +725,7 @@ void pgeditor_msg( // message display
image_win->AddMessage(msg);
}


#endif // GRAPHCICS_DISABLED
/**********************************************************************
* pgeditor_read_file()
*
Expand All @@ -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
Expand Down Expand Up @@ -1856,6 +1857,7 @@ BOOL8 word_toggle_seg( // toggle seg flag
return TRUE;
}

#endif // GRAPHICS_DISABLED

/* DEBUG ONLY */

Expand Down
57 changes: 0 additions & 57 deletions ccmain/tesseractmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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, &current_block_list);
tprintf ("Done reading files.\n");

PAGE_RES page_res(&current_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;

Expand Down
1 change: 0 additions & 1 deletion ccmain/tfacep.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);

Expand Down
2 changes: 0 additions & 2 deletions ccutil/mainblk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*
**********************************************************************/

#define BLOB_MATCHING_ON

#include "mfcpch.h"
#include "fileerr.h"
#ifdef __UNIX__
Expand Down
9 changes: 0 additions & 9 deletions ccutil/mainblk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion classify/adaptmatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -1203,6 +1204,7 @@ void AdaptToChar(TBLOB *Blob,
GetClassToDebug ("Adapting");
}
}
#endif // GRAPHICS_DISABLED
}
FreeFeatureSet(FloatFeatures);
}
Expand Down
3 changes: 0 additions & 3 deletions cutil/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
4 changes: 2 additions & 2 deletions dict/stopper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++))
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion makemoredists
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion textord/blobcmpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

class PBLOB;
class ROW;
#define BLOB_MATCHING_ON

float compare_blobs( //match 2 blobs
PBLOB *blob1, //first blob
Expand Down
3 changes: 3 additions & 0 deletions textord/drawedg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -72,3 +74,4 @@ void draw_raw_edge( //draw the cracks
while (edgept != start);
}

#endif // GRAPHICS_DISABLED
3 changes: 2 additions & 1 deletion textord/drawtord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -87,7 +88,6 @@ void create_todebug_win() { //make gradients win
to_debug = fopen (to_debugfile.string (), "w");
}


/**********************************************************************
* plot_blob_list
*
Expand Down Expand Up @@ -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
4 changes: 0 additions & 4 deletions textord/tordmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion training/cntraining.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
AssemblerListingLocation=".\cntrain.Release/"
ObjectFile=".\cntrain.Release/"
ProgramDataBaseFileName=".\cntrain.Release/"
BrowseInformation="2"
BrowseInformation="0"
BrowseInformationFile=".\cntrain.Release/"
WarningLevel="3"
SuppressStartupBanner="true"
Expand Down
7 changes: 6 additions & 1 deletion viewer/scrollview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
//
///////////////////////////////////////////////////////////////////////
//

#ifndef GRAPHICS_DISABLED
// This class contains the main ScrollView-logic,
// e.g. parsing & sending messages, images etc.
#ifdef WIN32
Expand All @@ -30,7 +32,7 @@ const int kMaxIntPairSize = 45; // Holds %d,%d, for upto 64 bit.
#include "scrollview.h"

#include <stdarg.h>
#include <string.h>
#include <string.h>
#include <map>
#include <utility>
#include <algorithm>
Expand Down Expand Up @@ -817,3 +819,6 @@ int ScrollView::TranslateYCoordinate(int y) {
if (!y_axis_is_reversed_) { return y;
} else { return y_size_ - y; }
}


#endif // GRAPHICS_DISABLED
3 changes: 3 additions & 0 deletions viewer/scrollview.h
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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__
4 changes: 4 additions & 0 deletions viewer/svmnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
// menu bars.
#include "svmnode.h"

#ifndef GRAPHICS_DISABLED

#include <iostream>
#include <cstring>

Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions viewer/svutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -341,3 +343,5 @@ SVNetwork::~SVNetwork() {
delete[] msg_buffer_in_;
delete mutex_send_;
}

#endif // GRAPHICS_DISABLED
2 changes: 2 additions & 0 deletions wordrec/drawfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "werd.h"
#include "drawfx.h"

#ifndef GRAPHICS_DISABLED
#define FXDEMOWIN "FXDemo"
#define FXDEMOXPOS 250
#define FXDEMOYPOS 0
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit bea5e04

Please sign in to comment.