X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=pctb%2Focr.h;h=60234a8e91e6028ea8f028a912f0a53d8eafbc7d;hb=0826bbc65e59d47c270f05af419f24fdfc3c349c;hp=0824404579f753ca9ba65dd4d224258f188fdb5f;hpb=ad09cd7cce6584c63c275d7ed1106e66959b3f9d;p=ypp-sc-tools.web-live.git diff --git a/pctb/ocr.h b/pctb/ocr.h index 0824404..60234a8 100644 --- a/pctb/ocr.h +++ b/pctb/ocr.h @@ -1,32 +1,68 @@ +/* + * ocr.c forms a mostly-self-contained bit + * so we put its declarations in this separate file + */ + #ifndef OCR_H #define OCR_H -#include -#include -#include -#include + +// #define DEBUG_RECTANGLES +// #define DEBUG_OCR + + +#define _GNU_SOURCE + #include +#include +#include +#include +#include #include +#include +#include +#include + #include #include + +typedef struct { + int w,h; + char d[]; +} CanonImage; + typedef uint32_t Pixcol; #define PSPIXCOL(priscan) priscan##32 typedef struct { const char *s; /* valid until next call to ocr() */ int l,r; /* column numbers */ - int ctx; /* match context index */ + unsigned ctxmap; /* match context index */ } OcrResultGlyph; -OcrResultGlyph *ocr(int w, int h, Pixcol cols[]); + +typedef const struct OcrCellTypeInfo *OcrCellType; +extern const struct OcrCellTypeInfo ocr_celltype_text; +extern const struct OcrCellTypeInfo ocr_celltype_number; + + +typedef struct OcrReader OcrReader; +OcrReader *ocr_init(int h); + +OcrResultGlyph *ocr(OcrReader *rd, OcrCellType, int w, Pixcol cols[]); /* return value is array terminated by {0,-1,-1} * array is valid until next call to ocr() */ -void ocr_init(void); + +/*----- debugging arrangements, rather contingent -----*/ + +void debug_flush(void); #define eassert assert -#define debug stdout +#define debug stderr + +const char *get_vardir(void); #endif /*OCR_H*/