X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=pctb%2Focr.h;h=a688742cc631f0bdb88b66bce1b3e8d360713794;hb=4d7fdf03d6fc476d7f591c9f8e5c41ebe6c06176;hp=d08ae15ba8b0878a990b0a135e39fbf84cdbb0e9;hpb=8787ee59f6840de63bac432b516a30d0dfe22c84;p=ypp-sc-tools.db-live.git diff --git a/pctb/ocr.h b/pctb/ocr.h index d08ae15..a688742 100644 --- a/pctb/ocr.h +++ b/pctb/ocr.h @@ -1,43 +1,83 @@ +/* + * ocr.c forms a mostly-self-contained bit + * so we put its declarations in this separate file + */ + #ifndef OCR_H #define OCR_H + #define _GNU_SOURCE -#include -#include -#include -#include #include -#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; -typedef const struct OcrGlyphContextDeveloperInfo *OcrCellContext; -extern const struct OcrGlyphContextDeveloperInfo *ocr_celltype_text; -extern const struct OcrGlyphContextDeveloperInfo *ocr_celltype_number; + +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, int w, Pixcol cols[]); +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() */ + +/*----- 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 -#define debug stdout +#define debug stderr const char *get_vardir(void);