ccmain/tessedit2.cpp File Reference

#include "mfcpch.h"
#include "tfacep.h"
#include "stderr.h"
#include "basedir.h"
#include "tessvars.h"
#include "control.h"
#include "imgs.h"
#include "reject.h"
#include "pageres.h"
#include "mainblk.h"
#include "nwmain.h"
#include "pgedit.h"
#include "varabled.h"
#include "ocrshell.h"
#include "tprintf.h"
#include "tessedit.h"
#include "applybox.h"
#include "permute.h"
#include "permdawg.h"
#include "permnum.h"
#include "stopper.h"
#include "adaptmatch.h"
#include "intmatcher.h"
#include "chop.h"
#include "globals.h"
#include "fileerr.h"
#include <io.h>
#include <stdlib.h>
#include "callnet.h"
#include "notdll.h"

Go to the source code of this file.

Defines

Functions

Variables


Define Documentation

#define _STR (  )     #a

#define _XSTR (  )     _STR(a)

Referenced by init_tesseract(), and main_setup().

#define API_CONFIG   "configs/api_config"

Definition at line 74 of file tessedit2.cpp.

#define BLOB_MATCHING_ON

Definition at line 78 of file tessedit2.cpp.

#define EXTERN

Definition at line 75 of file tessedit2.cpp.

#define FORCE_VAR_DUMP   0

Referenced by init_tesseract().

#define TESSDATA_PREFIX   /usr/local/tesseract-1.02/

Referenced by init_tesseract(), and main_setup().

#define VARDIR   "configs/"

Note:
File: tessedit.cpp (Formerly tessedit.c)
Main program for merge of tess and editor.
Author:
Ray Smith
Date:
Tue Jan 07 15:21:46 GMT 1992
 * (C) Copyright 1992, Hewlett-Packard Ltd.
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 ** http://www.apache.org/licenses/LICENSE-2.0
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.

Definition at line 79 of file tessedit2.cpp.

#define VARDIR   "configs/"

Note:
File: tessedit.cpp (Formerly tessedit.c)
Main program for merge of tess and editor.
Author:
Ray Smith
Date:
Tue Jan 07 15:21:46 GMT 1992
 * (C) Copyright 1992, Hewlett-Packard Ltd.
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 ** http://www.apache.org/licenses/LICENSE-2.0
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.

Definition at line 79 of file tessedit2.cpp.


Function Documentation

int init_tesseract ( const char *  arg0,
const char *  textbase,
const char *  configfile,
int  configc,
const char *const *  configv 
)

Initialize everything tess needs to run.

Parameters:
arg0 for main_setup()
textbase for main_setup()
configfile configuration file
configc for main_setup()
configv for main_setup()
Note:
Global: tessedit_use_nn, tessedit_write_vars, tweak_ReliableConfigThreshold
Returns:
status code

Definition at line 144 of file tessedit2.cpp.

References _XSTR, ABORT, CANTOPENFILE, datadir, DBG, demodir, ERRCODE::error(), FALSE, FORCE_VAR_DUMP, getpath(), imagebasename, init_net(), main_setup(), MAX_PATH, NO_PATH, NULL, print_variables(), read_variables_file(), ReliableConfigThreshold, set_tess_tweak_vars(), start_recog(), STRING::string(), TESSDATA_PREFIX, and VARDIR.

00148                                                {
00149   FILE *var_file;
00150   static char c_path[MAX_PATH];  //path for c code
00151 
00152   // Set the basename, compute the data directory and read C++ configs.
00153 
00154   // from ccutil/mainblk.cpp
00155   INT32 arg;                     /*argument */
00156   INT32 offset;                  //for flag
00157   FILE *fp;                      /*variables file */
00158   char flag[2];                  //+/-
00159   STRING varfile;                /*name of file */
00160 
00161   imagebasename = textbase;      /*name of image */
00162   if (getpath (arg0, datadir) < 0)
00163   #ifdef __UNIX__
00164     CANTOPENFILE.error ("main", ABORT, "%s to get path", arg0[0]);
00165   #else
00166   NO_PATH.error ("main", DBG, NULL);
00167   #endif
00168 
00169   for (arg = 0; arg < configc; arg++) {
00170     if (configv[arg][0] == '+' || configv[arg][0] == '-') {
00171       offset = 1;
00172       flag[0] = configv[arg][0];
00173     }
00174     else {
00175       offset = 0;
00176     }
00177     flag[offset] = '\0';
00178     varfile = flag;
00179                                  /*attempt open */
00180     fp = fopen (configv[arg] + offset, "r");
00181     if (fp != NULL) {
00182       fclose(fp);  /*was only to test */
00183     }
00184     else {
00185       varfile += datadir;
00186       varfile += m_data_sub_dir; /*data directory */
00187       varfile += VARDIR;         /*variables dir */
00188     }
00189                                  /*actual name */
00190     varfile += configv[arg] + offset;
00191     read_variables_file (varfile.string ());
00192   }
00193 
00194   if (m_print_variables)
00195     print_variables(stdout);  /*print them all */
00196 
00197 // Allows the required data files to be at a fixed location
00198 // not relative to the directory where the binary was executed
00199 // from a patch on the forums on sf.net - need to add attribution
00200 #define TESSDATA_PREFIX /usr/local/tesseract-1.02/
00201 
00202 #ifdef TESSDATA_PREFIX
00203 # define _STR(a) #a
00204 # define _XSTR(a) _STR(a)
00205   datadir = _XSTR(TESSDATA_PREFIX);
00206 # undef _XSTR
00207 # undef _STR
00208 #endif
00209 
00210   datadir += m_data_sub_dir;     /*data directory */
00211   #ifdef __UNIX__
00212   if (memgrab_size > 0) {
00213     void *membuf;                //test virtual mem
00214                                  //test memory
00215     membuf = malloc (memgrab_size);
00216     if (membuf == NULL) {
00217       raise(SIGTTOU);  //hangup for jobber
00218       sleep (10);
00219     }
00220     else
00221       free(membuf); 
00222   }
00223   #endif
00224   debug_window_on.set_value (FALSE);
00225 
00226 #define FORCE_VAR_DUMP 0   // set to 1 to make variables file
00227 
00228   if (tessedit_write_vars || FORCE_VAR_DUMP) {
00229     var_file = fopen ("edited.cfg", "w");
00230     if (var_file != NULL) {
00231       print_variables(var_file); 
00232       fclose(var_file); 
00233     }
00234   }
00235   strcpy (c_path, datadir.string ());
00236   c_path[strlen (c_path) - strlen (m_data_sub_dir.string ())] = '\0';
00237   demodir = c_path;
00238   start_recog(configfile, textbase); 
00239 
00240   ReliableConfigThreshold = tweak_ReliableConfigThreshold;
00241 
00242   set_tess_tweak_vars(); 
00243 
00244   if (tessedit_use_nn)           //Phils NeuralNet stuff
00245     init_net(); 
00246   return 0;                      //Normal exit
00247 }


Variable Documentation

EXTERN DLLSYM STRING datadir

Note:
File: mainblk.h (Formerly main.h)
Function to call from main() to setup.
Author:
Ray Smith
Date:
Tue Oct 22 11:09:40 BST 1991
 * (C) Copyright 1991, Hewlett-Packard Ltd.
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 ** http://www.apache.org/licenses/LICENSE-2.0
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.

Definition at line 81 of file tessedit2.cpp.

Referenced by build_main_var_menu(), init_tesseract(), and main_setup().

ETEXT_DESC* global_monitor = NULL

progress monitor

Definition at line 130 of file tessedit2.cpp.

EXTERN DLLSYM STRING imagebasename

Definition at line 82 of file tessedit2.cpp.

Referenced by adapt_to_good_ems(), adapt_to_good_samples(), build_menu(), choice_dump_tester(), do_view_cmd(), init_tesseract(), main_setup(), open_outfile(), and smd_cmd().

int NO_BLOCK

Definition at line 53 of file output.cpp.

const ERRCODE NO_PATH

Initial value:

"Warning:explicit path for executable will not be used for configs"

Definition at line 83 of file tessedit2.cpp.

Referenced by init_tesseract(), and main_setup().

const ERRCODE USAGE = "Usage" [static]

Definition at line 85 of file tessedit2.cpp.

Referenced by main().

INT16 XOFFSET

Definition at line 56 of file output.cpp.

INT16 YOFFSET

Definition at line 57 of file output.cpp.


Generated on Wed Feb 28 19:49:15 2007 for Tesseract by  doxygen 1.5.1