00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef OCRBLOCK_H
00021 #define OCRBLOCK_H
00022
00023 #include "img.h"
00024 #include "ocrrow.h"
00025 #include "pdblock.h"
00026
00027 class BLOCK;
00028
00029 ELISTIZEH_S (BLOCK)
00030 class BLOCK:public ELIST_LINK, public PDBLK
00031
00032 {
00033 friend class BLOCK_RECT_IT;
00034
00035 public:
00036 BLOCK()
00037 : re_rotation_(1.0f, 0.0f),
00038 classify_rotation_(1.0f, 0.0f),
00039 skew_(1.0f, 0.0f) {
00040 hand_poly = NULL;
00041 }
00042 BLOCK(const char *name,
00043 BOOL8 prop,
00044 inT16 kern,
00045 inT16 space,
00046 inT16 xmin,
00047 inT16 ymin,
00048 inT16 xmax,
00049 inT16 ymax);
00050
00051 ~BLOCK () {
00052 }
00053
00054
00055 void set_stats(BOOL8 prop,
00056 inT16 kern,
00057 inT16 space,
00058 inT16 ch_pitch) {
00059 proportional = prop;
00060 kerning = (inT8) kern;
00061 spacing = space;
00062 pitch = ch_pitch;
00063 }
00064 void set_xheight(inT32 height) {
00065 xheight = height;
00066 }
00067 void set_font_class(inT16 font) {
00068 font_class = font;
00069 }
00070 BOOL8 prop() const {
00071 return proportional;
00072 }
00073 inT32 fixed_pitch() const {
00074 return pitch;
00075 }
00076 inT16 kern() const {
00077 return kerning;
00078 }
00079 inT16 font() const {
00080 return font_class;
00081 }
00082 inT16 space() const {
00083 return spacing;
00084 }
00085 const char *name() const {
00086 return filename.string ();
00087 }
00088 inT32 x_height() const {
00089 return xheight;
00090 }
00091 float cell_over_xheight() const {
00092 return cell_over_xheight_;
00093 }
00094 void set_cell_over_xheight(float ratio) {
00095 cell_over_xheight_ = ratio;
00096 }
00097 ROW_LIST *row_list() {
00098 return &rows;
00099 }
00100 C_BLOB_LIST *blob_list() {
00101 return &c_blobs;
00102 }
00103 C_BLOB_LIST *reject_blobs() {
00104 return &rej_blobs;
00105 }
00106 FCOORD re_rotation() const {
00107 return re_rotation_;
00108 }
00109 void set_re_rotation(const FCOORD& rotation) {
00110 re_rotation_ = rotation;
00111 }
00112 FCOORD classify_rotation() const {
00113 return classify_rotation_;
00114 }
00115 void set_classify_rotation(const FCOORD& rotation) {
00116 classify_rotation_ = rotation;
00117 }
00118 FCOORD skew() const {
00119 return skew_;
00120 }
00121 void set_skew(const FCOORD& skew) {
00122 skew_ = skew;
00123 }
00124 const ICOORD& median_size() const {
00125 return median_size_;
00126 }
00127 void set_median_size(int x, int y) {
00128 median_size_.set_x(x);
00129 median_size_.set_y(y);
00130 }
00131
00132 void rotate(const FCOORD& rotation);
00133
00134 void sort_rows();
00135
00136 void compress();
00137
00138 void check_pitch();
00139
00140 void compress(const ICOORD vec);
00141
00142 void print(FILE *fp, BOOL8 dump);
00143
00144 void prep_serialise() {
00145 filename.prep_serialise();
00146 rows.prep_serialise();
00147 c_blobs.prep_serialise();
00148 rej_blobs.prep_serialise();
00149 leftside.prep_serialise();
00150 rightside.prep_serialise();
00151 }
00152
00153 void dump(FILE *f) {
00154 filename.dump(f);
00155 rows.dump(f);
00156 c_blobs.dump(f);
00157 rej_blobs.dump(f);
00158 leftside.dump(f);
00159 rightside.dump(f);
00160 }
00161
00162 void de_dump(FILE *f) {
00163 filename.de_dump(f);
00164 rows.de_dump(f);
00165 c_blobs.de_dump(f);
00166 rej_blobs.de_dump(f);
00167 leftside.de_dump(f);
00168 rightside.de_dump(f);
00169 }
00170
00171 make_serialise(BLOCK)
00172
00173 BLOCK& operator=(const BLOCK & source);
00174
00175 private:
00176 BOOL8 proportional;
00177 inT8 kerning;
00178 inT16 spacing;
00179 inT16 pitch;
00180 inT16 font_class;
00181 inT32 xheight;
00182 float cell_over_xheight_;
00183 STRING filename;
00184 ROW_LIST rows;
00185 C_BLOB_LIST c_blobs;
00186 C_BLOB_LIST rej_blobs;
00187 FCOORD re_rotation_;
00188 FCOORD classify_rotation_;
00189 FCOORD skew_;
00190 ICOORD median_size_;
00191 };
00192
00193 int decreasing_top_order(const void *row1, const void *row2);
00194
00195 #endif