reference/ocr-simple/main.cc
changeset 0 6b8091ca909a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reference/ocr-simple/main.cc	Thu May 18 23:12:51 2006 +0200
@@ -0,0 +1,92 @@
+#include <tcl.h>
+#include <tk.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <cstdlib>
+#include <math.h>
+#include "system.h"
+#include "Page.h"
+#include "tcl_interface.h"
+
+
+#define QUIT 0
+#define PAUSE 0
+
+/*
+
+Creates a tcl interpereter, link variable capabilities,
+and "docommand" function--Thanks to: Keiji Kanazawa
+
+To execute a line in tcl:  (set x 4)
+
+docommand("set x 4");
+
+also
+
+docommand("set x %d", 4);  
+
+or
+
+docommand("set %s %d", "x", 4);   this might not work ("x" on the stack) 
+
+started 10/95 Archie Russell
+
+*/
+
+
+
+Tcl_Interp* TCL_ip;
+Tk_Window main_window;
+Page* global_page = new Page;
+
+
+int main(int argc, char** argv)
+{
+  initialize_interpreter();
+  initialize_command_procs();
+  initialize_link_vars();
+  if(ENABLE_USER_INTERFACE)
+      {
+	load_user_interface();
+      }
+
+  Page * testPage;
+  int return_code;
+  testPage = new Page;
+  if(ENABLE_USER_INTERFACE)
+    readLearnFiles();
+  else
+    {
+      if(argc == 3 && strcmp(argv[2], "nolearn") == 0)
+	readLearnedGroups("learnedGroups.dat");
+      else
+	{
+	  learn("train.tif", "train.txt");
+	  writeLearnedGroups("learnedGroups.dat");
+	}
+    }
+  if(!ENABLE_USER_INTERFACE) {
+    testPage->readMap(argv[1]);
+    testPage->deskew(0);
+    testPage->setLines();
+    testPage->extractComponents();
+    testPage->recognize();
+    testPage->extractWords();
+    testPage->printComponents();
+    testPage->writeWordPos("wordpos.out");
+    testPage->writeAscii("ascii.out");
+    delete testPage;
+  }  
+  if(ENABLE_USER_INTERFACE)
+  while(1)
+      {
+	Tcl_DoOneEvent(TCL_DONT_WAIT);  //6/21/00
+      }
+  exit(0);
+}
+
+
+
+
+