chiark / gitweb /
WIP actual useful structure
[ypp-sc-tools.db-test.git] / pctb / ocr.h
1 /*
2  * ocr.c forms a mostly-self-contained bit
3  * so we put its declarations in this separate file
4  */
5
6 #ifndef OCR_H
7 #define OCR_H
8
9
10 // #define DEBUG_RECTANGLES
11 // #define DEBUG_OCR
12
13
14 #define _GNU_SOURCE
15
16 #include <string.h>
17 #include <stdio.h>
18 #include <errno.h>
19 #include <assert.h>
20 #include <stdint.h>
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <stdarg.h>
24 #include <inttypes.h>
25
26 #include <sys/types.h>
27 #include <sys/wait.h>
28
29
30 typedef struct {
31   int w,h;
32   char d[];
33 } CanonImage;
34
35 typedef uint32_t Pixcol;
36 #define PSPIXCOL(priscan) priscan##32
37
38 typedef struct {
39   const char *s; /* valid until next call to ocr() */
40   int l,r; /* column numbers */
41   unsigned ctxmap; /* match context index */
42 } OcrResultGlyph;
43
44
45 typedef const struct OcrCellTypeInfo *OcrCellType;
46 extern const struct OcrCellTypeInfo ocr_celltype_text;
47 extern const struct OcrCellTypeInfo ocr_celltype_number;
48
49
50 typedef struct OcrReader OcrReader;
51 OcrReader *ocr_init(int h);
52
53 OcrResultGlyph *ocr(OcrReader *rd, OcrCellType, int w, Pixcol cols[]);
54   /* return value is array terminated by {0,-1,-1}
55    * array is valid until next call to ocr()
56    */
57
58
59 /*----- debugging arrangements, rather contingent -----*/
60
61 void debug_flush(void);
62
63 #define eassert assert
64 #define debug stderr
65
66 const char *get_vardir(void);
67
68 #endif /*OCR_H*/