5 #define DEBUG_RECTANGLES
23 #include <sys/types.h>
34 typedef uint32_t Pixcol;
35 #define PSPIXCOL(priscan) priscan##32
38 const char *s; /* valid until next call to ocr() */
39 int l,r; /* column numbers */
40 unsigned ctxmap; /* match context index */
43 typedef const struct OcrCellTypeInfo *OcrCellType;
44 extern const struct OcrCellTypeInfo ocr_celltype_text;
45 extern const struct OcrCellTypeInfo ocr_celltype_number;
47 typedef struct OcrReader OcrReader;
48 OcrReader *ocr_init(int h);
50 OcrResultGlyph *ocr(OcrReader *rd, OcrCellType, int w, Pixcol cols[]);
51 /* return value is array terminated by {0,-1,-1}
52 * array is valid until next call to ocr()
55 void debug_flush(void);
57 #define eassert assert
60 const char *get_vardir(void);
62 CanonImage *file_read_image(FILE *f);
66 extern CanonImage *page_images[MAX_PAGES];
71 unsigned long rgb; /* on screen */
72 char c; /* canonical */
75 extern const CanonColourInfo canoncolourinfos[];
77 CanonImage *alloc_canon_image(int w, int h);
79 #ifdef DEBUG_RECTANGLES
80 # define CANIMG_DEBUG_RECTANGLE_1LINE(im,w,h) \
81 fprintf(debug, "%4d ",y); \
82 r= fwrite(im->d + y*w, 1,w, debug); \
86 # define CANIMG_DEBUG_RECTANGLE_1LINE(im,y,h) /* nothing */
89 #define CANONICALISE_IMAGE(im,w,h, COMPUTE_RGB) do{ \
90 /* compute_rgb should be a number of statements, or \
91 * a block, which assigns to \
92 * unsigned long rgb; \
93 * given the values of \
95 * all of which are anamorphic. Result is stored in im. \
97 (im)= alloc_canon_image((w), (h)); \
100 for (y=0; y<(h); y++) { \
101 for (x=0; x<(w); x++) { \
102 const CanonColourInfo *cci; \
105 for (cci=canoncolourinfos; cci->c; cci++) \
106 if (cci->rgb == rgb) { \
107 (im)->d[y*(w) + x]= cci->c; \
111 CANIMG_DEBUG_RECTANGLE_1LINE((im),(w),(h)) \