1 #ifndef TESSCLAS_H 2 #define TESSCLAS_H 1 3 4 #define SPLINESIZE 23 /*max spline parts to a line */ 5 6 #define TBLOBFLAGS 4 /*No of flags in a blob */ 7 #define MAX_WO_CLASSES 3 8 #define EDGEPTFLAGS 4 /*concavity,length etc. */ 9 10 typedef struct 11 { 12 double a; /*x squared */ 13 double b; /*x */ 14 double c; /*constant */ 15 } QUAD_SPEC; /*definiton of quadratic */ 16 17 typedef struct 18 { 19 int segments; /*no of spline segments */ 20 int xstarts[SPLINESIZE]; /*start x coords */ 21 QUAD_SPEC quads[SPLINESIZE]; /*quadratic sections */ 22 } SPLINE_SPEC; /*quadratic spline */ 23 24 typedef struct 25 { 26 short x; /*absolute x coord */ 27 short y; /*absolute y coord */ 28 } TPOINT; 29 typedef TPOINT VECTOR; /*structure for coordinates */ 30 31 typedef struct 32 { 33 char dx; /*compact vectors */ 34 char dy; 35 } BYTEVEC; 36 37 typedef struct edgeptstruct 38 { 39 TPOINT pos; /*position */ 40 VECTOR vec; /*vector to next point */ 41 char flags[EDGEPTFLAGS]; /*concavity, length etc */ 42 struct edgeptstruct *next; /*anticlockwise element */ 43 struct edgeptstruct *prev; /*clockwise element */ 44 } EDGEPT; /*point on expanded outline */ 45 46 typedef struct blobstruct 47 { 48 struct olinestruct *outlines; /*list of outlines in blob */ 49 char flags[TBLOBFLAGS]; /*blob flags */ 50 char correct; /*correct text */ 51 char guess; /*best guess */ 52 /*quickie classification */ 53 unsigned char classes[MAX_WO_CLASSES]; 54 /*quickie ratings */ 55 unsigned char values[MAX_WO_CLASSES]; 56 struct blobstruct *next; /*next blob in block */ 57 } TBLOB; /*blob structure */ 58 59 typedef struct olinestruct 60 { 61 TPOINT topleft; /*top left of loop */ 62 TPOINT botright; /*bottom right of loop */ 63 TPOINT start; /*start of loop */ 64 BYTEVEC *compactloop; /*ptr to compacted loop */ 65 EDGEPT *loop; /*edgeloop */ 66 void *node; /*1st node on outline */ 67 struct olinestruct *next; /*next at this level */ 68 struct olinestruct *child; /*inner outline */ 69 } TESSLINE; /*outline structure */ 70 71 typedef struct wordstruct 72 { 73 struct textrowstruct *row; /*row it came from */ 74 char *correct; /*correct word string */ 75 char *guess; /*guess word string */ 76 TBLOB *blobs; /*blobs in word */ 77 int blanks; /*blanks before word */ 78 int blobcount; /*no of blobs in word */ 79 struct wordstruct *next; /*next word */ 80 } TWERD; /*word structure */ 81 82 typedef struct textrowstruct 83 { 84 int blobcount; /** count of blobs in row. **/ 85 TBLOB *blobs; /*list of blobs in row */ 86 TWERD *words; /*list of words in row */ 87 int mean_y; /** y coordinate of centre of row **/ 88 int max_y; /** y coordinate of top of row **/ 89 int min_y; /** y coordinate of bottom of row **/ 90 SPLINE_SPEC xheight; /*top of row */ 91 SPLINE_SPEC baseline; /*bottom of row */ 92 float descdrop; /*descender drop */ 93 float ascrise; /*ascender rise */ 94 float lineheight; /*average xheight-baseline */ 95 int kerning; /*kerning of row */ 96 int space; /*spacing of row */ 97 float space_threshold; /*Bayesian space limit */ 98 int p_spaced; /*proportinal flag */ 99 int b_space; /*block spacing */ 100 int b_kern; /*block kerning */ 101 struct textrowstruct *next; /*next row in block */ 102 } TEXTROW; 103 104 typedef struct blockstruct /** list of coordinates **/ 105 { 106 TBLOB *blobs; /*blobs in block */ 107 TEXTROW *rows; /*rows in block */ 108 int blobcount; /*no of blobs */ 109 short xmin; 110 short xmax; 111 short ymin; 112 short ymax; 113 char type; /** block type **/ 114 char p_spaced; /** flag to show propertianal spacing **/ 115 short rowcount; /** number of rows **/ 116 short leading; /** space between rows **/ 117 short kerning; /** space between characters **/ 118 short space; /** distance between char centres **/ 119 short minwidth; /*min width of char in block */ 120 short p_size; /** point size of text **/ 121 short l_margin; /** posn of left margin **/ 122 short italic; /** flag to show italic block **/ 123 short spurious; /** percentage of spurious characters **/ 124 struct blockstruct *next; /*next text block */ 125 } TEXTBLOCK; /*block from image */ 126 127 /********************************************************************** 128 * iterate_blobs 129 * 130 * Visit all the words in a list using a local variable. 131 **********************************************************************/ 132 133 #define iterate_blobs(blob,blobs) \ 134 for (blob = blobs; blob != NULL; blob = blob->next) 135 #endif 136