#include <ocrblock.h>
|
| BLOCK () |
|
| BLOCK (const char *name, bool prop, int16_t kern, int16_t space, int16_t xmin, int16_t ymin, int16_t xmax, int16_t ymax) |
|
| ~BLOCK ()=default |
|
void | set_stats (bool prop, int16_t kern, int16_t space, int16_t ch_pitch) |
|
void | set_xheight (int32_t height) |
| set char size More...
|
|
void | set_font_class (int16_t font) |
| set font class More...
|
|
bool | prop () const |
| return proportional More...
|
|
bool | right_to_left () const |
|
void | set_right_to_left (bool value) |
|
int32_t | fixed_pitch () const |
| return pitch More...
|
|
int16_t | kern () const |
| return kerning More...
|
|
int16_t | font () const |
| return font class More...
|
|
int16_t | space () const |
| return spacing More...
|
|
const char * | name () const |
| return filename More...
|
|
int32_t | x_height () const |
| return xheight More...
|
|
float | cell_over_xheight () const |
|
void | set_cell_over_xheight (float ratio) |
|
ROW_LIST * | row_list () |
| get rows More...
|
|
void | compute_row_margins () |
|
PARA_LIST * | para_list () |
|
C_BLOB_LIST * | blob_list () |
| get blobs More...
|
|
C_BLOB_LIST * | reject_blobs () |
|
FCOORD | re_rotation () const |
|
void | set_re_rotation (const FCOORD &rotation) |
|
FCOORD | classify_rotation () const |
|
void | set_classify_rotation (const FCOORD &rotation) |
|
FCOORD | skew () const |
|
void | set_skew (const FCOORD &skew) |
|
const ICOORD & | median_size () const |
|
void | set_median_size (int x, int y) |
|
Pix * | render_mask (TBOX *mask_box) |
|
TBOX | restricted_bounding_box (bool upper_dots, bool lower_dots) const |
|
void | reflect_polygon_in_y_axis () |
|
void | rotate (const FCOORD &rotation) |
|
void | sort_rows () |
| decreasing y order More...
|
|
void | compress () |
| shrink white space More...
|
|
void | check_pitch () |
| check proportional More...
|
|
void | compress (const ICOORD vec) |
| shrink white space and move by vector More...
|
|
void | print (FILE *fp, bool dump) |
| dump whole table More...
|
|
BLOCK & | operator= (const BLOCK &source) |
|
| ELIST_LINK () |
|
| ELIST_LINK (const ELIST_LINK &) |
|
void | operator= (const ELIST_LINK &) |
|
Definition at line 28 of file ocrblock.h.
◆ BLOCK() [1/2]
Definition at line 33 of file ocrblock.h.
35 : re_rotation_(1.0f, 0.0f),
36 classify_rotation_(1.0f, 0.0f),
◆ BLOCK() [2/2]
BLOCK::BLOCK |
( |
const char * |
name, |
|
|
bool |
prop, |
|
|
int16_t |
kern, |
|
|
int16_t |
space, |
|
|
int16_t |
xmin, |
|
|
int16_t |
ymin, |
|
|
int16_t |
xmax, |
|
|
int16_t |
ymax |
|
) |
| |
BLOCK::BLOCK
Constructor for a simple rectangular block.
- Parameters
-
name | filename |
prop | proportional |
kern | kerning |
space | spacing |
xmin | bottom left |
xmax | top right |
Definition at line 30 of file ocrblock.cpp.
38 :
pdblk(xmin, ymin, xmax, ymax),
40 re_rotation_(1.0f, 0.0f),
41 classify_rotation_(1.0f, 0.0f),
50 cell_over_xheight_ = 2.0f;
55 left_it.add_to_end (
new ICOORDELT (xmin, ymin));
56 left_it.add_to_end (
new ICOORDELT (xmin, ymax));
57 right_it.add_to_end (
new ICOORDELT (xmax, ymin));
58 right_it.add_to_end (
new ICOORDELT (xmax, ymax));
◆ ~BLOCK()
◆ blob_list()
C_BLOB_LIST* BLOCK::blob_list |
( |
| ) |
|
|
inline |
◆ cell_over_xheight()
float BLOCK::cell_over_xheight |
( |
| ) |
const |
|
inline |
Definition at line 108 of file ocrblock.h.
110 return cell_over_xheight_;
◆ check_pitch()
void BLOCK::check_pitch |
( |
| ) |
|
check proportional
BLOCK::check_pitch
Check whether the block is fixed or prop, set the flag, and set the pitch if it is fixed.
Definition at line 163 of file ocrblock.cpp.
◆ classify_rotation()
FCOORD BLOCK::classify_rotation |
( |
| ) |
const |
|
inline |
Definition at line 139 of file ocrblock.h.
141 return classify_rotation_;
◆ compress() [1/2]
shrink white space
BLOCK::compress
Delete space between the rows. (And maybe one day, compress the rows) Fill space of block from top down, left aligning rows.
Definition at line 125 of file ocrblock.cpp.
127 #define ROW_SPACING 5
129 ROW_IT row_it(&rows);
133 ICOORDELT_IT icoordelt_it;
139 for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
140 row = row_it.data ();
◆ compress() [2/2]
void BLOCK::compress |
( |
const ICOORD |
vec | ) |
|
◆ compute_row_margins()
void BLOCK::compute_row_margins |
( |
| ) |
|
Definition at line 326 of file ocrblock.cpp.
342 ROW *first_row = r_it.data();
343 ROW *second_row = r_it.data_relative(1);
351 WERD_IT werd_it(r_it.data()->word_list());
352 if (!werd_it.empty()) {
353 C_BLOB_IT cblob_it(werd_it.data()->cblob_list());
354 for (cblob_it.mark_cycle_pt(); !cblob_it.cycled_list();
355 cblob_it.forward()) {
356 TBOX bbox = cblob_it.data()->bounding_box();
357 if (bbox.
bottom() <= mid_second_line) {
360 if (drop_cap_bottom > bbox.
bottom())
361 drop_cap_bottom = bbox.
bottom();
362 if (drop_cap_right < bbox.
right())
363 drop_cap_right = bbox.
right();
372 for (r_it.mark_cycle_pt(); !r_it.cycled_list(); r_it.forward()) {
373 ROW *row = r_it.data();
377 const std::unique_ptr< ICOORDELT_LIST> segments_left(
378 lines.get_line(left_y));
379 LeftMargin(segments_left.get(), row_box.
left(), &left_margin);
381 if (row_box.
top() >= drop_cap_bottom) {
382 int drop_cap_distance = row_box.
left() - row->
space() - drop_cap_right;
383 if (drop_cap_distance < 0)
384 drop_cap_distance = 0;
385 if (drop_cap_distance < left_margin)
386 left_margin = drop_cap_distance;
391 const std::unique_ptr< ICOORDELT_LIST> segments_right(
392 lines.get_line(right_y));
393 RightMargin(segments_right.get(), row_box.
right(), &right_margin);
◆ fixed_pitch()
int32_t BLOCK::fixed_pitch |
( |
| ) |
const |
|
inline |
◆ font()
int16_t BLOCK::font |
( |
| ) |
const |
|
inline |
◆ kern()
int16_t BLOCK::kern |
( |
| ) |
const |
|
inline |
◆ median_size()
const ICOORD& BLOCK::median_size |
( |
| ) |
const |
|
inline |
◆ name()
const char* BLOCK::name |
( |
| ) |
const |
|
inline |
◆ operator=()
BLOCK::operator=
Assignment - duplicate the block structure, but with an EMPTY row list.
Definition at line 221 of file ocrblock.cpp.
227 proportional = source.proportional;
228 kerning = source.kerning;
229 spacing = source.spacing;
230 filename = source.filename;
233 re_rotation_ = source.re_rotation_;
234 classify_rotation_ = source.classify_rotation_;
235 skew_ = source.skew_;
◆ para_list()
PARA_LIST* BLOCK::para_list |
( |
| ) |
|
|
inline |
◆ print()
void BLOCK::print |
( |
FILE * |
fp, |
|
|
bool |
dump |
|
) |
| |
dump whole table
BLOCK::print
Print the info on a block
- Parameters
-
fp | file to print on |
dump | print full detail |
Definition at line 189 of file ocrblock.cpp.
197 tprintf (
"Proportional= %s\n", proportional ?
"TRUE" :
"FALSE");
198 tprintf (
"Kerning= %d\n", kerning);
199 tprintf (
"Spacing= %d\n", spacing);
200 tprintf (
"Fixed_pitch=%d\n", pitch);
204 tprintf (
"Left side coords are:\n");
205 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
206 tprintf (
"(%d,%d) ", it.data ()->x (), it.data ()->y ());
208 tprintf (
"Right side coords are:\n");
210 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
211 tprintf (
"(%d,%d) ", it.data ()->x (), it.data ()->y ());
◆ prop()
bool BLOCK::prop |
( |
| ) |
const |
|
inline |
return proportional
Definition at line 75 of file ocrblock.h.
◆ re_rotation()
FCOORD BLOCK::re_rotation |
( |
| ) |
const |
|
inline |
◆ reflect_polygon_in_y_axis()
void BLOCK::reflect_polygon_in_y_axis |
( |
| ) |
|
◆ reject_blobs()
C_BLOB_LIST* BLOCK::reject_blobs |
( |
| ) |
|
|
inline |
◆ render_mask()
Pix* BLOCK::render_mask |
( |
TBOX * |
mask_box | ) |
|
|
inline |
◆ restricted_bounding_box()
TBOX BLOCK::restricted_bounding_box |
( |
bool |
upper_dots, |
|
|
bool |
lower_dots |
|
) |
| const |
Definition at line 84 of file ocrblock.cpp.
88 ROW_IT it(const_cast<ROW_LIST*>(&rows));
89 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
90 box += it.data()->restricted_bounding_box(upper_dots, lower_dots);
◆ right_to_left()
bool BLOCK::right_to_left |
( |
| ) |
const |
|
inline |
Definition at line 78 of file ocrblock.h.
80 return right_to_left_;
◆ rotate()
void BLOCK::rotate |
( |
const FCOORD & |
rotation | ) |
|
◆ row_list()
ROW_LIST* BLOCK::row_list |
( |
| ) |
|
|
inline |
◆ set_cell_over_xheight()
void BLOCK::set_cell_over_xheight |
( |
float |
ratio | ) |
|
|
inline |
Definition at line 111 of file ocrblock.h.
113 cell_over_xheight_ = ratio;
◆ set_classify_rotation()
void BLOCK::set_classify_rotation |
( |
const FCOORD & |
rotation | ) |
|
|
inline |
Definition at line 142 of file ocrblock.h.
144 classify_rotation_ = rotation;
◆ set_font_class()
void BLOCK::set_font_class |
( |
int16_t |
font | ) |
|
|
inline |
◆ set_median_size()
void BLOCK::set_median_size |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
|
inline |
◆ set_re_rotation()
void BLOCK::set_re_rotation |
( |
const FCOORD & |
rotation | ) |
|
|
inline |
Definition at line 136 of file ocrblock.h.
138 re_rotation_ = rotation;
◆ set_right_to_left()
void BLOCK::set_right_to_left |
( |
bool |
value | ) |
|
|
inline |
Definition at line 81 of file ocrblock.h.
83 right_to_left_ = value;
◆ set_skew()
void BLOCK::set_skew |
( |
const FCOORD & |
skew | ) |
|
|
inline |
◆ set_stats()
void BLOCK::set_stats |
( |
bool |
prop, |
|
|
int16_t |
kern, |
|
|
int16_t |
space, |
|
|
int16_t |
ch_pitch |
|
) |
| |
|
inline |
set space size etc.
- Parameters
-
prop | proportional |
kern | inter char size |
space | inter word size |
ch_pitch | pitch if fixed |
Definition at line 57 of file ocrblock.h.
63 kerning = static_cast<int8_t>(
kern);
◆ set_xheight()
void BLOCK::set_xheight |
( |
int32_t |
height | ) |
|
|
inline |
◆ skew()
◆ sort_rows()
void BLOCK::sort_rows |
( |
| ) |
|
decreasing y order
BLOCK::sort_rows
Order rows so that they are in order of decreasing Y coordinate
Definition at line 111 of file ocrblock.cpp.
113 ROW_IT row_it(&rows);
115 row_it.sort (decreasing_top_order);
◆ space()
int16_t BLOCK::space |
( |
| ) |
const |
|
inline |
◆ x_height()
int32_t BLOCK::x_height |
( |
| ) |
const |
|
inline |
◆ BLOCK_RECT_IT
◆ pdblk
Page Description Block.
Definition at line 189 of file ocrblock.h.
The documentation for this class was generated from the following files: