chiark / gitweb /
seems to be able to do most scanning
[ypp-sc-tools.web-live.git] / pctb / ocr.c
index 04aecc0d48a0431642d73c85f8b65144fa74b491..48c25c085661579d75d4eca2622802dcfb19151c 100644 (file)
@@ -24,6 +24,8 @@ static const char *context_names[]= {
 
 #define NCONTEXTS (sizeof(context_names)/sizeof(context_names[0]))
 
+#define SPACE_SPACES 3
+
 struct OcrReader {
   int h;
   DatabaseNode contexts[NCONTEXTS];
@@ -305,13 +307,16 @@ OcrResultGlyph *ocr(OcrReader *rd, OcrCellType ct, int w, Pixcol cols[]) {
     if (!cols[x]) {
       nspaces++;
       x++;
-      if (nspaces==3) {
+      if (nspaces==SPACE_SPACES) {
        fprintf(debug,"OCR  x=%x nspaces=%d space\n",x,nspaces);
-       add_result(rd," ",x-nspaces,x+1,0);
        ctxmap= ct->nextword;
       }
       continue;
     }
+
+    /* something here, so we need to add the spaces */
+    if (nspaces>=SPACE_SPACES)
+      add_result(rd," ",x-nspaces,x+1,0);
     nspaces=0;
 
     /* find character */