polygon intersector: added horizontal line reconstruction
[swftools.git] / lib / gocr / ocr0.h
1 #ifndef _OCR0_H
2 #define _OCR0_H
3 #include "pgm2asc.h"
4
5 /* ----------------------------------------------------------------
6    - functions with thousand of lines make the compilation very slow
7      therefore the ocr0-function is splitted in subfunctions
8    - shared data used often in ocr0-subroutines are stored
9      in ocr0_shared structure.
10  *  ------------------------------------------------------------  */
11
12 typedef struct ocr0_shared {  /* shared variables and properties */
13
14   struct box *box1;  /* box in whole image */
15   pix *bp;           /* extracted temporarly box, cleaned */
16   int cs;            /* global threshold value (gray level) */
17
18                       /* ToDo: or MACROS: X0 = box1->x0 */
19   int x0, x1, y0, y1; /* box coordinates related to box1 */
20   int dx, dy;         /* size of box */
21   int hchar, gchar;   /* relation to m1..m4 */
22   int aa[4][4];       /* corner points, see xX (x,y,dist^2,vector_idx) v0.41 */
23   holes_t holes;      /* list of holes (max MAX_HOLES) */
24
25 } ocr0_shared_t;
26
27 /* tests for umlaut */
28 int testumlaut(struct box *box1, int cs, int m, wchar_t *modifier);
29 /* detect chars */
30 wchar_t ocr0(struct box *box1, pix  *b, int cs);
31 /* detect numbers */
32 wchar_t ocr0n(ocr0_shared_t *sdata);
33
34 static inline int sq(int x) { return x*x; } /* square */
35
36 /*
37  * go from vector j1 to vector j2 and measure maximum deviation of
38  *   the steps from the line connecting j1 and j2
39  * return the squared maximum distance
40  *   in units of the box size times 1024
41  */ 
42 int line_deviation( struct box *box1, int j1, int j2 );
43
44 /*
45  * search vectors between j1 and j2 for nearest point a to point r 
46  * example:
47  * 
48  *     r-> $$...$$   $ - mark vectors
49  *         @@$..@@   @ - black pixels
50  *         @@$..@@   . - white pixels
51  *         @@@@.$@
52  *     a-> @@$@$@@
53  *         @$.@@@@
54  *         @@..$@@
55  *         @@..$@@
56  *  j1 --> $$...$$ <-- j2
57  *     
58  * ToDo: vector aa[5] = {rx,ry,x,y,d^2,idx} statt rx,ry?
59  *          j1 and j2 must be in the same frame
60  *          return aa?
61  */
62 int nearest_frame_vector( struct box *box1, int j1, int j2, int rx, int ry);
63 #endif