|
1 #ifndef _COMPONENT_H |
|
2 #define _COMPONENT_H |
|
3 #include "system.h" |
|
4 #include "list.h" |
|
5 #include "RLEMap.h" |
|
6 |
|
7 class BitMap; |
|
8 |
|
9 class Components: public List |
|
10 { |
|
11 public: |
|
12 Components(); |
|
13 ~Components(); |
|
14 |
|
15 |
|
16 }; |
|
17 |
|
18 class Component{ |
|
19 public: |
|
20 |
|
21 Component(Point ul, Point lr) |
|
22 :ful(ul), flr(lr), fnumBits(0),fasciiId(0), fconfid(0), |
|
23 charGroup(0), ffontId(0) |
|
24 { fproperty = new Property[numProperties]; |
|
25 for (int i = 0; i < numProperties; i++) |
|
26 fproperty[i] = 0;}; |
|
27 |
|
28 Component() |
|
29 :ful(-1), flr(-1), fnumBits(0),fasciiId(0),fconfid(0), |
|
30 charGroup(0), ffontId(0) |
|
31 { fproperty = new Property[numProperties]; |
|
32 for (int i = 0; i < numProperties; i++) |
|
33 fproperty[i] = 0;}; |
|
34 ~Component(){ |
|
35 if (fproperty != NULL) delete fproperty;} |
|
36 |
|
37 |
|
38 inline Point & ul() {return ful;}; |
|
39 inline Point & lr() {return flr;}; |
|
40 |
|
41 inline double width() {return (double)(flr.x() - ful.x() + 1); }; |
|
42 inline double height() {return (double)(flr.y() - ful.y() + 1); }; |
|
43 inline int & numBits(){return fnumBits;}; |
|
44 short int charGroup; // values 0-3: 0=acemno, 1=gpqy, 2=dfhikl, 3=j([} |
|
45 int vertShrink(BitMap * bitmap); |
|
46 int AddToComponent(ListElement* intrvl, RLEMap* rlemap); |
|
47 /*-------------------------------------------------------------- |
|
48 Primary Purpose: Extend boundaries of component by connected intervals. |
|
49 Arguments: startIntrvl is interval to start from |
|
50 Return Value: Number of intervals added. |
|
51 Effects: Updates component's LR and UL. Deletes all added intervals. |
|
52 ----------------------------------------------------------------*/ |
|
53 |
|
54 // Access entire property vector |
|
55 inline Property * properties() |
|
56 {return fproperty;} |
|
57 |
|
58 // Set or read one value in property vector |
|
59 inline Property & property(int p) // Possibly use overload [] |
|
60 {return fproperty[p];}; |
|
61 |
|
62 // Set or read ascii id; |
|
63 inline Character & asciiId(){ return fasciiId;}; |
|
64 |
|
65 // Set or read font id; |
|
66 inline short int & fontId() {return ffontId;}; |
|
67 |
|
68 inline Confidence & confid(){ return fconfid; }; |
|
69 // Determine heuristic distance between this and comp |
|
70 Distance distance(Component * comp); |
|
71 |
|
72 // Use the BitMap map to set the property vector for |
|
73 // this component |
|
74 |
|
75 void setProperties(RLEMap * map); |
|
76 void setProperties(BitMap * map); |
|
77 void setSectionFlags(short int hflag[], short int vflag[]); |
|
78 |
|
79 void display_bounding_box(); |
|
80 |
|
81 Distance recognize(Component * learnedchars); |
|
82 // find best match in learned characters. Set ascii value |
|
83 // and return distance. |
|
84 |
|
85 Distance recognize(Components * learnedgroups, bool allGroups=FALSE); |
|
86 // find best match from learned character groups. Set ascii value |
|
87 // and return distance. |
|
88 |
|
89 Property * fproperty; |
|
90 private: |
|
91 Point ful; |
|
92 Point flr; |
|
93 int fnumBits; |
|
94 |
|
95 |
|
96 Character fasciiId; |
|
97 short int ffontId; |
|
98 Confidence fconfid; |
|
99 }; |
|
100 |
|
101 |
|
102 #endif |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |