X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=blobdiff_plain;f=pctb%2Focr.c;h=87bf80842a510280e30826d8fe36c877911b59e8;hp=a90ecea64e590641911a3faa5e250373ce16863c;hb=a7c52a5cdad0b1a4c4e053992858674e8d7953a7;hpb=ad09cd7cce6584c63c275d7ed1106e66959b3f9d diff --git a/pctb/ocr.c b/pctb/ocr.c index a90ecea..87bf808 100644 --- a/pctb/ocr.c +++ b/pctb/ocr.c @@ -186,11 +186,18 @@ OcrResultGlyph *ocr(int w, int h, Pixcol cols[]) { nresults=0; assert(db); + fprintf(debug,"OCR h=%d w=%d",w,h); + for (x=0; x=w) break; + if (x>=w) + break; if (!cols[x]) { nspaces++; @@ -204,34 +211,50 @@ OcrResultGlyph *ocr(int w, int h, Pixcol cols[]) { int lx=x; int bestmatch_rx=-1; current= &ocr_contexts[ctx]; + fprintf(debug,"OCR lx=%d ctx=%d ",lx,ctx); + for (;;) { + debug_flush(); + fprintf(debug,"| x=%d",x); if (x>w) break; Pixcol cv= cols[x]; + fprintf(debug," cv=%"PSPIXCOL(PRIx),x); for (i=0; inlinks; i++) if (current->links[i].col == cv) goto found; /* not found */ + fprintf(debug," ?"); break; + found: current= current->links[i].then; - if (current->s[0]) { bestmatch=current; bestmatch_rx=x; } + if (current->s[0]) { + fprintf(debug," \"%s\"",current->s); + bestmatch=current; bestmatch_rx=x; + } else { + fprintf(debug," ..."); + } x++; } - if (!bestmatch) { + if (bestmatch) { + fprintf(debug," YES\n"); add_result(bestmatch->s, lx, bestmatch_rx, ctx); x= bestmatch_rx+1; ctx= 0; } else { - int rx; + fprintf(debug," UNKNOWN"); for (rx=lx+1; rx