chiark / gitweb /
much fixes for new arrangements
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 6 Jun 2009 19:17:13 +0000 (20:17 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 6 Jun 2009 19:17:13 +0000 (20:17 +0100)
pctb/charset-15.txt
pctb/convert.c
pctb/ocr.c
pctb/ocr.h
pctb/pages.c
pctb/show-thing.tcl
pctb/structure.c
pctb/structure.h

index d2478da95e3f7ac8e054cfd0c278c8ad9a22fff0..99aeff144349f766e0576b79c7d59310a2a70743 100644 (file)
@@ -120,6 +120,14 @@ A
 600
 800
 
+Lower
+B
+ff8
+888
+888
+888
+770
+
 Lower
 D
 ff8
@@ -137,6 +145,24 @@ ff8
 88
 88
 
+Lower
+H
+ff8
+80
+80
+80
+80
+80
+ff8
+
+Lower
+It
+ff8
+0
+20
+7f0
+820
+
 Lower
 J
 2000
@@ -153,6 +179,24 @@ c0
 408
 800
 
+Lower
+L
+ff8
+800
+800
+800
+800
+
+Lower
+M
+ff8
+30
+1c0
+600
+1c0
+30
+ff8
+
 Lower
 N
 ff8
@@ -264,6 +308,12 @@ Lower
 i
 fe8
 
+Lower
+j
+2000
+2000
+1fe8
+
 Lower
 k
 ff8
@@ -380,6 +430,14 @@ c00
 380
 60
 
+Lower
+x
+820
+6c0
+100
+6c0
+820
+
 Lower
 y
 60
@@ -495,6 +553,14 @@ Upper
 I
 ff8
 
+Upper
+It
+ff8
+0
+20
+7f0
+820
+
 Upper
 J
 2000
@@ -576,6 +642,15 @@ ff8
 8
 8
 
+Upper
+U
+7f8
+800
+800
+800
+800
+7f8
+
 Upper
 V
 18
index f38abf5a0d2dc6b0c91eaa4fd3e78a271e581bda..5f47113bdaaa93a52913b2dde95a4ae55fc25015 100644 (file)
@@ -31,6 +31,11 @@ int main(int argc, char **argv) {
       o_single_page= 1;
     else if (!strcmp(arg,"--screenshots-file"))
       eassert( o_screenshots_fn= *++argv );
+#define DF(f)                                  \
+    else if (!strcmp(arg,"-D" #f))             \
+      debug_flags |= dbg_##f;
+    DEBUG_FLAG_LIST
+#undef DF
     else if (!strcmp(arg,"--window-id")) {
       char *ep;
       eassert((arg=*++argv));
index 7eb871a68844acc1d802747e67346aed760b3729..436aa8dc16078ae830b54de0e1e7468c71bcb4fd 100644 (file)
@@ -24,7 +24,7 @@ static const char *context_names[]= {
 
 #define NCONTEXTS (sizeof(context_names)/sizeof(context_names[0]))
 
-#define SPACE_SPACES 3
+#define SPACE_SPACES 4
 
 struct OcrReader {
   int h;
@@ -185,7 +185,9 @@ static void callout_unknown(OcrReader *rd, int w, Pixcol cols[],
        * so we aren't in any danger of overwriting some other fd 4: */
       r= dup2(donepipe[1],4); eassert(r==4);
       execlp("./show-thing.tcl", "./show-thing.tcl",
-            "--automatic","1",(char*)0);
+            DEBUGP(callout) ? "--debug" : "--noop-arg",
+            "--automatic-1",
+            (char*)0);
       eassert(!"execlp failed");
     }
     r= close(jobpipe[0]); eassert(!r);
@@ -287,9 +289,8 @@ const struct OcrCellTypeInfo ocr_celltype_text= {
 };
 
 static void vdebugf(const char *fmt, va_list al) {
-#ifdef DEBUG_OCR
-  vfprintf(debug,fmt,al);
-#endif
+  if (DEBUGP(ocr))
+    vfprintf(debug,fmt,al);
 }
 static void debugf(const char *fmt, ...) {
   va_list al;  va_start(al,fmt);  vdebugf(fmt,al);  va_end(al);
index 60234a8e91e6028ea8f028a912f0a53d8eafbc7d..a688742cc631f0bdb88b66bce1b3e8d360713794 100644 (file)
@@ -7,10 +7,6 @@
 #define OCR_H
 
 
-// #define DEBUG_RECTANGLES
-// #define DEBUG_OCR
-
-
 #define _GNU_SOURCE
 
 #include <string.h>
@@ -58,6 +54,26 @@ OcrResultGlyph *ocr(OcrReader *rd, OcrCellType, int w, Pixcol cols[]);
 
 /*----- debugging arrangements, rather contingent -----*/
 
+#define DEBUG_FLAG_LIST                                \
+   DF(ocr)                                     \
+   DF(rect)                                    \
+   DF(callout)
+
+enum {
+#define DF(f) dbg__shift_##f,
+  DEBUG_FLAG_LIST
+#undef DF
+};
+enum {
+#define DF(f) dbg_##f = 1 << dbg__shift_##f,
+  DEBUG_FLAG_LIST
+#undef DF
+};
+
+unsigned debug_flags;
+
+#define DEBUGP(f) (!!(debug_flags & dbg_##f))
+
 void debug_flush(void);
 
 #define eassert assert
index 361ea0ea9926b4cf576d1cdaedfafa5e00370477..360e71858fd5699ac0a8f933e67c4f4fad818e08 100644 (file)
@@ -249,7 +249,7 @@ void take_screenshots(void) {
 
   /* find the window and check it's on the right kind of screen */
   raise_and_get_details();
-  snapshot(&current);
+  wait_for_stability(&current,0,0);
   test= convert_page(current);
   find_structure(test);
   free(test);
@@ -286,7 +286,7 @@ void take_one_screenshot(void) {
   
   raise_and_get_details();
   sync_after_input();
-  snapshot(&current);
+  wait_for_stability(&current,0,0);
   page_images[0]= convert_page(current);
   npages= 1;
 }
index c04d4ddf21b897e56d323e0c1ac17d40a14f8ea3..5356c3292c7c58a276944752d6b16c325b1f5090 100755 (executable)
@@ -26,10 +26,6 @@ set gotsh 20
 set csrh 20
 set ctxh 20
 
-proc debug {m} {
-    puts stderr "SHOW-THING $m"
-}
-
 proc init_widgets {} {
     # idempotent
     global csrh gotsh ctxh
@@ -525,6 +521,7 @@ proc required {} {
     debug "GOT $l"
 
     fileevent stdin readable {}
+    fconfigure stdin -blocking yes
 
     read_xpm stdin
     resize_widgets
@@ -539,14 +536,20 @@ proc main/automatic {} {
 }
 proc done/automatic {} {
     exec sh -c {printf \\0 >&4}
-    fileevent stdin readable required
+    main/automatic
 }
 
-switch -exact -- $argv {
-    {}               { set mainkind test }
-    {--automatic 1}  { set mainkind automatic }
-    {--automatic*}   { error "incompatible versions - install problem" }
-    default          { error "huh $argv ?" }
+proc debug {m} { }
+
+set mainkind test
+foreach arg $argv {
+    switch -exact -- $arg {
+       {--debug}        { proc debug {m} { puts stderr "SHOW-THING $m" } }
+       {--noop-arg}     { }
+       {--automatic-1}  { set mainkind automatic }
+       {--automatic*}   { error "incompatible versions - install problem" }
+       default          { error "huh $argv ?" }
+    }
 }
 
 main/$mainkind
index fc077c1f31a72cd4d5d9df6734bb9562aad46f77..f9f1e7f52b1c8cf08328fe8a05a0446f0bc3452f 100644 (file)
@@ -77,7 +77,7 @@ static void require_rectangle_r(Rect rr, const char *ok) {
 }
 
 static void debug_rect(const char *what, int whati, Rect rr) {
-#ifdef DEBUG_RECTANGLES
+  if (!DEBUGP(rect)) return;
   int y,r,w;
   fprintf(debug, "%s %d: %d,%d..%d,%d:\n", what, whati,
          rr.tl.x,rr.tl.y, rr.br.x,rr.br.y);
@@ -89,7 +89,6 @@ static void debug_rect(const char *what, int whati, Rect rr) {
     fputc('|',debug);
     fputc('\n',debug);
   }
-#endif
   debug_flush();
 }
 
@@ -152,17 +151,17 @@ void find_structure(CanonImage *im) {
   down.y++;
   WALK_UNTIL_MUST(down, y,+1, mainr.br.y, '+');
 
-#ifdef DEBUG_RECTANGLES
-  int xscaleunit, y,x;
-  for (y=0, xscaleunit=1; y<4; y++, xscaleunit*=10) {
-    fprintf(debug,"     ");
-    for (x=0; x<=cim->w; x++) {
-      if (x % xscaleunit) fputc(' ',debug);
-      else fprintf(debug,"%d",(x / xscaleunit)%10);
+  if (DEBUGP(rect)) {
+    int xscaleunit, y,x;
+    for (y=0, xscaleunit=1; y<4; y++, xscaleunit*=10) {
+      fprintf(debug,"     ");
+      for (x=0; x<=cim->w; x++) {
+       if (x % xscaleunit) fputc(' ',debug);
+       else fprintf(debug,"%d",(x / xscaleunit)%10);
+      }
+      fputc('\n',debug);
     }
-    fputc('\n',debug);
   }
-#endif
 
   commbasey= up.y;
   comminty= down.y - up.y + 2;
@@ -230,13 +229,13 @@ CanonImage *file_read_image_ppm(FILE *f) {
 }
 
 void read_screenshots(void) {
-  int c;
-  while ((c= fgetc(screenshots_file) != EOF)) {
-    ungetc(c, screenshots_file);
+//  int c;
+//  while ((c= fgetc(screenshots_file) != EOF)) {
+//    ungetc(c, screenshots_file);
 
-    eassert(npages < MAX_PAGES);
+//    eassert(npages < MAX_PAGES);
     page_images[npages++]= file_read_image_ppm(screenshots_file);
-  }
+//  }
 }
 
 static void find_commodity(int offset, Rect *rr) {
index 10de443ed6e55169520bea1d7e4e57fd3610bb05..b246c87ba2acf20579998ea13532116fbc644bc7 100644 (file)
@@ -14,16 +14,6 @@ extern const CanonColourInfo canoncolourinfos[];
 
 CanonImage *alloc_canon_image(int w, int h);
 
-#ifdef DEBUG_RECTANGLES
-# define CANIMG_DEBUG_RECTANGLE_1LINE(im,w,h)  \
-      fprintf(debug, "%4d ",y);                        \
-      int r= fwrite(im->d + y*w, 1,w, debug);  \
-      eassert(r==w);                           \
-      fputc('\n',debug);
-#else
-# define CANIMG_DEBUG_RECTANGLE_1LINE(im,y,h) /* nothing */
-#endif
-
 #define CANONICALISE_IMAGE(im,w,h, COMPUTE_RGB) do{            \
     /* compute_rgb should be a number of statements, or                \
      * a block, which assigns to                               \
@@ -48,7 +38,12 @@ CanonImage *alloc_canon_image(int w, int h);
            break;                                              \
          }                                                     \
       }                                                                \
-      CANIMG_DEBUG_RECTANGLE_1LINE((im),(w),(h))               \
+      if (DEBUGP(rect)) {                                      \
+       fprintf(debug, "%4d ",y);                               \
+       int r= fwrite(im->d + y*w, 1,w, debug);                 \
+       eassert(r==w);                                          \
+       fputc('\n',debug);                                      \
+      }                                                                \
     }                                                          \
     debug_flush();                                             \
   }while(0)