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 void find_structure(CanonImage *im);
59 #define eassert assert
62 const char *get_vardir(void);
64 CanonImage *file_read_image(FILE *f);
68 extern CanonImage *page_images[MAX_PAGES];
73 unsigned long rgb; /* on screen */
74 char c; /* canonical */
77 extern const CanonColourInfo canoncolourinfos[];
79 CanonImage *alloc_canon_image(int w, int h);
81 #ifdef DEBUG_RECTANGLES
82 # define CANIMG_DEBUG_RECTANGLE_1LINE(im,w,h) \
83 fprintf(debug, "%4d ",y); \
84 r= fwrite(im->d + y*w, 1,w, debug); \
88 # define CANIMG_DEBUG_RECTANGLE_1LINE(im,y,h) /* nothing */
91 #define CANONICALISE_IMAGE(im,w,h, COMPUTE_RGB) do{ \
92 /* compute_rgb should be a number of statements, or \
93 * a block, which assigns to \
94 * unsigned long rgb; \
95 * given the values of \
97 * all of which are anamorphic. Result is stored in im. \
99 (im)= alloc_canon_image((w), (h)); \
102 for (y=0; y<(h); y++) { \
103 for (x=0; x<(w); x++) { \
104 const CanonColourInfo *cci; \
107 for (cci=canoncolourinfos; cci->c; cci++) \
108 if (cci->rgb == rgb) { \
109 (im)->d[y*(w) + x]= cci->c; \
113 CANIMG_DEBUG_RECTANGLE_1LINE((im),(w),(h)) \