|
1 #include <tcl.h> |
|
2 #include <tk.h> |
|
3 #include <stdio.h> |
|
4 #include <stdarg.h> |
|
5 #include <string.h> |
|
6 #include <stdlib.h> |
|
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 |
|
42 Page* global_page = new ZonedPage; |
|
43 Page* active_page= NULL; |
|
44 Page* zoned_page = NULL; |
|
45 |
|
46 int |
|
47 main(int argc, char** argv) |
|
48 { |
|
49 initialize_interpreter(); |
|
50 initialize_command_procs(); |
|
51 initialize_link_vars(); |
|
52 if(ENABLE_USER_INTERFACE) |
|
53 { |
|
54 load_user_interface(); |
|
55 } |
|
56 |
|
57 Page * testPage; |
|
58 int return_code; |
|
59 testPage = new Page; |
|
60 if(ENABLE_USER_INTERFACE) |
|
61 readLearnFiles(); |
|
62 else |
|
63 { |
|
64 if(argc == 3 && strcmp(argv[2], "nolearn") == 0) |
|
65 readLearnedGroups("learnedGroups.dat"); |
|
66 else |
|
67 { |
|
68 learn("train.tif", "train.txt",0); |
|
69 learn("4.header.tif", "4.header.txt",1); |
|
70 learn("4.col0.tif", "4.col0.txt", 1); |
|
71 writeLearnedGroups("learnedGroups.dat"); |
|
72 } |
|
73 } |
|
74 if(!ENABLE_USER_INTERFACE) { |
|
75 testPage->readMap(argv[1]); |
|
76 testPage->deskew(0); |
|
77 testPage->setLines(); |
|
78 testPage->extractComponents(MinHorizSeparation); |
|
79 testPage->recognize(); |
|
80 testPage->extractWords(); |
|
81 testPage->printComponents(); |
|
82 testPage->writeWordPos("wordpos.out"); |
|
83 testPage->writeWordbox("wordbox.out",0,0,0); |
|
84 testPage->writeAscii("ascii.out"); |
|
85 testPage->addEquation(2 , 200, 4, 100); |
|
86 printf(" in eqn ? %d",testPage->inEquation(450, 105)); |
|
87 printf (" deleted? %d", testPage->deleteEquation(400, 100)); // deletes equation with this coordinate. |
|
88 delete testPage; |
|
89 } |
|
90 if(ENABLE_USER_INTERFACE) |
|
91 while(1) |
|
92 { |
|
93 Tk_DoOneEvent(TK_ALL_EVENTS); |
|
94 } |
|
95 |
|
96 exit(0); |
|
97 } |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |