00001 #ifndef TESSCLAS_H 00002 #define TESSCLAS_H 1 00003 00004 #define SPLINESIZE 23 /*max spline parts to a line */ 00005 00006 #define TBLOBFLAGS 4 /*No of flags in a blob */ 00007 #define MAX_WO_CLASSES 3 00008 #define EDGEPTFLAGS 4 /*concavity,length etc. */ 00009 00010 typedef struct 00011 { 00012 double a; /*x squared */ 00013 double b; /*x */ 00014 double c; /*constant */ 00015 } QUAD_SPEC; /*definiton of quadratic */ 00016 00017 typedef struct 00018 { 00019 int segments; /*no of spline segments */ 00020 int xstarts[SPLINESIZE]; /*start x coords */ 00021 QUAD_SPEC quads[SPLINESIZE]; /*quadratic sections */ 00022 } SPLINE_SPEC; /*quadratic spline */ 00023 00024 typedef struct 00025 { 00026 short x; /*absolute x coord */ 00027 short y; /*absolute y coord */ 00028 } TPOINT; 00029 typedef TPOINT VECTOR; /*structure for coordinates */ 00030 00031 typedef struct 00032 { 00033 char dx; /*compact vectors */ 00034 char dy; 00035 } BYTEVEC; 00036 00037 typedef struct edgeptstruct 00038 { 00039 TPOINT pos; /*position */ 00040 VECTOR vec; /*vector to next point */ 00041 char flags[EDGEPTFLAGS]; /*concavity, length etc */ 00042 struct edgeptstruct *next; /*anticlockwise element */ 00043 struct edgeptstruct *prev; /*clockwise element */ 00044 } EDGEPT; /*point on expanded outline */ 00045 00046 typedef struct blobstruct 00047 { 00048 struct olinestruct *outlines; /*list of outlines in blob */ 00049 char flags[TBLOBFLAGS]; /*blob flags */ 00050 char correct; /*correct text */ 00051 char guess; /*best guess */ 00052 /*quickie classification */ 00053 unsigned char classes[MAX_WO_CLASSES]; 00054 /*quickie ratings */ 00055 unsigned char values[MAX_WO_CLASSES]; 00056 struct blobstruct *next; /*next blob in block */ 00057 } TBLOB; /*blob structure */ 00058 00059 typedef struct olinestruct 00060 { 00061 TPOINT topleft; /*top left of loop */ 00062 TPOINT botright; /*bottom right of loop */ 00063 TPOINT start; /*start of loop */ 00064 BYTEVEC *compactloop; /*ptr to compacted loop */ 00065 EDGEPT *loop; /*edgeloop */ 00066 void *node; /*1st node on outline */ 00067 struct olinestruct *next; /*next at this level */ 00068 struct olinestruct *child; /*inner outline */ 00069 } TESSLINE; /*outline structure */ 00070 00071 typedef struct wordstruct 00072 { 00073 struct textrowstruct *row; /*row it came from */ 00074 char *correct; /*correct word string */ 00075 char *guess; /*guess word string */ 00076 TBLOB *blobs; /*blobs in word */ 00077 int blanks; /*blanks before word */ 00078 int blobcount; /*no of blobs in word */ 00079 struct wordstruct *next; /*next word */ 00080 } TWERD; /*word structure */ 00081 00082 typedef struct textrowstruct 00083 { 00084 int blobcount; 00085 TBLOB *blobs; /*list of blobs in row */ 00086 TWERD *words; /*list of words in row */ 00087 int mean_y; 00088 int max_y; 00089 int min_y; 00090 SPLINE_SPEC xheight; /*top of row */ 00091 SPLINE_SPEC baseline; /*bottom of row */ 00092 float descdrop; /*descender drop */ 00093 float ascrise; /*ascender rise */ 00094 float lineheight; /*average xheight-baseline */ 00095 int kerning; /*kerning of row */ 00096 int space; /*spacing of row */ 00097 float space_threshold; /*Bayesian space limit */ 00098 int p_spaced; /*proportinal flag */ 00099 int b_space; /*block spacing */ 00100 int b_kern; /*block kerning */ 00101 struct textrowstruct *next; /*next row in block */ 00102 } TEXTROW; 00103 00104 typedef struct blockstruct 00105 { 00106 TBLOB *blobs; /*blobs in block */ 00107 TEXTROW *rows; /*rows in block */ 00108 int blobcount; /*no of blobs */ 00109 short xmin; 00110 short xmax; 00111 short ymin; 00112 short ymax; 00113 char type; 00114 char p_spaced; 00115 short rowcount; 00116 short leading; 00117 short kerning; 00118 short space; 00119 short minwidth; /*min width of char in block */ 00120 short p_size; 00121 short l_margin; 00122 short italic; 00123 short spurious; 00124 struct blockstruct *next; /*next text block */ 00125 } TEXTBLOCK; /*block from image */ 00126 00127 /********************************************************************** 00128 * iterate_blobs 00129 * 00130 * Visit all the words in a list using a local variable. 00131 **********************************************************************/ 00132 00133 #define iterate_blobs(blob,blobs) \ 00134 for (blob = blobs; blob != NULL; blob = blob->next) 00135 #endif