reference/ocr-simple/main.cc
changeset 0 6b8091ca909a
equal deleted inserted replaced
-1:000000000000 0:6b8091ca909a
       
     1 #include <tcl.h>
       
     2 #include <tk.h>
       
     3 #include <stdio.h>
       
     4 #include <stdarg.h>
       
     5 #include <string.h>
       
     6 #include <cstdlib>
       
     7 #include <math.h>
       
     8 #include "system.h"
       
     9 #include "Page.h"
       
    10 #include "tcl_interface.h"
       
    11 
       
    12 
       
    13 #define QUIT 0
       
    14 #define PAUSE 0
       
    15 
       
    16 /*
       
    17 
       
    18 Creates a tcl interpereter, link variable capabilities,
       
    19 and "docommand" function--Thanks to: Keiji Kanazawa
       
    20 
       
    21 To execute a line in tcl:  (set x 4)
       
    22 
       
    23 docommand("set x 4");
       
    24 
       
    25 also
       
    26 
       
    27 docommand("set x %d", 4);  
       
    28 
       
    29 or
       
    30 
       
    31 docommand("set %s %d", "x", 4);   this might not work ("x" on the stack) 
       
    32 
       
    33 started 10/95 Archie Russell
       
    34 
       
    35 */
       
    36 
       
    37 
       
    38 
       
    39 Tcl_Interp* TCL_ip;
       
    40 Tk_Window main_window;
       
    41 Page* global_page = new Page;
       
    42 
       
    43 
       
    44 int main(int argc, char** argv)
       
    45 {
       
    46   initialize_interpreter();
       
    47   initialize_command_procs();
       
    48   initialize_link_vars();
       
    49   if(ENABLE_USER_INTERFACE)
       
    50       {
       
    51 	load_user_interface();
       
    52       }
       
    53 
       
    54   Page * testPage;
       
    55   int return_code;
       
    56   testPage = new Page;
       
    57   if(ENABLE_USER_INTERFACE)
       
    58     readLearnFiles();
       
    59   else
       
    60     {
       
    61       if(argc == 3 && strcmp(argv[2], "nolearn") == 0)
       
    62 	readLearnedGroups("learnedGroups.dat");
       
    63       else
       
    64 	{
       
    65 	  learn("train.tif", "train.txt");
       
    66 	  writeLearnedGroups("learnedGroups.dat");
       
    67 	}
       
    68     }
       
    69   if(!ENABLE_USER_INTERFACE) {
       
    70     testPage->readMap(argv[1]);
       
    71     testPage->deskew(0);
       
    72     testPage->setLines();
       
    73     testPage->extractComponents();
       
    74     testPage->recognize();
       
    75     testPage->extractWords();
       
    76     testPage->printComponents();
       
    77     testPage->writeWordPos("wordpos.out");
       
    78     testPage->writeAscii("ascii.out");
       
    79     delete testPage;
       
    80   }  
       
    81   if(ENABLE_USER_INTERFACE)
       
    82   while(1)
       
    83       {
       
    84 	Tcl_DoOneEvent(TCL_DONT_WAIT);  //6/21/00
       
    85       }
       
    86   exit(0);
       
    87 }
       
    88 
       
    89 
       
    90 
       
    91 
       
    92