chiark / gitweb /
wip fetching images from X
[ypp-sc-tools.main.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 <sys/types.h>
15 #include <sys/wait.h>
16
17
18 typedef struct {
19   int w,h;
20   char d[];
21 } CanonImage;
22
23
24 typedef uint32_t Pixcol;
25 #define PSPIXCOL(priscan) priscan##32
26
27 typedef struct {
28   const char *s; /* valid until next call to ocr() */
29   int l,r; /* column numbers */
30   unsigned ctxmap; /* match context index */
31 } OcrResultGlyph;
32
33 typedef const struct OcrCellTypeInfo *OcrCellType;
34 extern const struct OcrCellTypeInfo ocr_celltype_text;
35 extern const struct OcrCellTypeInfo ocr_celltype_number;
36
37 typedef struct OcrReader OcrReader;
38 OcrReader *ocr_init(int h);
39
40 OcrResultGlyph *ocr(OcrReader *rd, OcrCellType, int w, Pixcol cols[]);
41   /* return value is array terminated by {0,-1,-1}
42    * array is valid until next call to ocr()
43    */
44
45 void debug_flush(void);
46
47 #define eassert assert
48 #define debug stdout
49
50 const char *get_vardir(void);
51
52 CanonImage *file_read_image(FILE *f);
53 int main_test(void);
54
55
56 #define DEBUG_RECTANGLES
57 // #define DEBUG_OCR
58
59 #endif /*OCR_H*/