chiark / gitweb /
d9a25f7a790da26812b5352a5d397f4c94e18352
[ypp-sc-tools.db-test.git] / pctb / ocr.h
1 #ifndef OCR_H
2 #define OCR_H
3
4 #define _GNU_SOURCE
5
6 #include <pam.h>
7 #include <stdint.h>
8 #include <inttypes.h>
9 #include <assert.h>
10 #include <string.h>
11 #include <stdlib.h>
12 #include <stdio.h>
13 #include <stdarg.h>
14 #include <time.h>
15
16 #include <sys/types.h>
17 #include <sys/wait.h>
18 #include <sys/time.h>
19
20
21 typedef struct {
22   int w,h;
23   char d[];
24 } CanonImage;
25
26
27 typedef uint32_t Pixcol;
28 #define PSPIXCOL(priscan) priscan##32
29
30 typedef struct {
31   const char *s; /* valid until next call to ocr() */
32   int l,r; /* column numbers */
33   unsigned ctxmap; /* match context index */
34 } OcrResultGlyph;
35
36 typedef const struct OcrCellTypeInfo *OcrCellType;
37 extern const struct OcrCellTypeInfo ocr_celltype_text;
38 extern const struct OcrCellTypeInfo ocr_celltype_number;
39
40 typedef struct OcrReader OcrReader;
41 OcrReader *ocr_init(int h);
42
43 OcrResultGlyph *ocr(OcrReader *rd, OcrCellType, int w, Pixcol cols[]);
44   /* return value is array terminated by {0,-1,-1}
45    * array is valid until next call to ocr()
46    */
47
48 void debug_flush(void);
49
50 #define eassert assert
51 #define debug stdout
52
53 const char *get_vardir(void);
54
55 CanonImage *file_read_image(FILE *f);
56 int main_test(void);
57
58 #define MAX_PAGES 100
59 extern CanonImage *page_images[MAX_PAGES];
60 extern int npages;
61
62
63 #define DEBUG_RECTANGLES
64 // #define DEBUG_OCR
65
66 #endif /*OCR_H*/