Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Friends
ROW Class Reference

`#include <ocrrow.h>`

Inheritance diagram for ROW:

List of all members.

## Public Member Functions

| ROW ()
| ROW (inT32 spline_size, inT32 *xstarts, double *coeffs, float x_height, float ascenders, float descenders, inT16 kern, inT16 space)
| ROW (TO_ROW *row, inT16 kern, inT16 space)
WERD_LIST * | word_list ()
float | base_line (float xpos) const
float | x_height () const
void | set_x_height (float new_xheight)
inT32 | kern () const
float | body_size () const
void | set_body_size (float new_size)
inT32 | space () const
float | ascenders () const
float | descenders () const
TBOX | bounding_box () const
void | set_lmargin (inT16 lmargin)
void | set_rmargin (inT16 rmargin)
inT16 | lmargin () const
inT16 | rmargin () const
void | set_has_drop_cap (bool has)
bool | has_drop_cap () const
void | set_para (PARA *p)
PARA * | para () const
void | recalc_bounding_box ()
void | move (const ICOORD vec)
void | print (FILE *fp)
void | plot (ScrollView *window, ScrollView::Color colour)
void | plot (ScrollView *window)
void | plot_baseline (ScrollView *window, ScrollView::Color colour)
ROW & | operator= (const ROW &source)
Public Member Functions inherited from ELIST_LINK
| ELIST_LINK ()
| ELIST_LINK (const ELIST_LINK &)
void | operator= (const ELIST_LINK &)

## Friends

void | tweak_row_baseline (ROW *, double, double)

## Detailed Description

Definition at line 32 of file ocrrow.h.

## Constructor & Destructor Documentation

ROW::ROW | ( |  | ) |

inline

Definition at line 36 of file ocrrow.h.

{
} //empty constructor

ROW::ROW | ( | inT32 | spline_size,
|  | inT32 * | xstarts,
|  | double * | coeffs,
|  | float | x_height,
|  | float | ascenders,
|  | float | descenders,
|  | inT16 | kern,
|  | inT16 | space
| ) |  |

Definition at line 36 of file ocrrow.cpp.

: baseline(spline_size, xstarts, coeffs),
para_(NULL) {
kerning = kern; //just store stuff
spacing = space;
xheight = x_height;
ascrise = ascenders;
bodysize = 0.0f;
descdrop = descenders;
has_drop_cap_ = false;
lmargin_ = 0;
rmargin_ = 0;
}

ROW::ROW | ( | TO_ROW * | row,
|  | inT16 | kern,
|  | inT16 | space
| ) |  |

Definition at line 67 of file ocrrow.cpp.

: para_(NULL) {
kerning = kern; //just store stuff
spacing = space;
xheight = to_row->xheight;
bodysize = to_row->body_size;
ascrise = to_row->ascrise;
descdrop = to_row->descdrop;
baseline = to_row->baseline;
has_drop_cap_ = false;
lmargin_ = 0;
rmargin_ = 0;
}

## Member Function Documentation

float ROW::ascenders | ( |  | ) | const

inline

Definition at line 79 of file ocrrow.h.

{ //return size
return ascrise;
}

float ROW::base_line | ( | float | xpos | ) | const

inline

Definition at line 56 of file ocrrow.h.

{ //at the position
//get spline value
return (float) baseline.y (xpos);
}

float ROW::body_size | ( |  | ) | const

inline

Definition at line 70 of file ocrrow.h.

{ //return body size
return bodysize;
}

TBOX ROW::bounding_box | ( |  | ) | const

inline

Definition at line 85 of file ocrrow.h.

{ //return bounding box
return bound_box;
}

float ROW::descenders | ( |  | ) | const

inline

Definition at line 82 of file ocrrow.h.

{ //return size
return descdrop;
}

bool ROW::has_drop_cap | ( |  | ) | const

inline

Definition at line 105 of file ocrrow.h.

{
return has_drop_cap_;
}

inT32 ROW::kern | ( |  | ) | const

inline

Definition at line 67 of file ocrrow.h.

{ //return kerning
return kerning;
}

inT16 ROW::lmargin | ( |  | ) | const

inline

Definition at line 95 of file ocrrow.h.

{
return lmargin_;
}

void ROW::move | ( | const ICOORD | vec | ) |

Definition at line 138 of file ocrrow.cpp.

{
WERD_IT it(&words); // word iterator
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
it.data ()->move (vec);
bound_box.move (vec);
baseline.move (vec);
}

ROW & ROW::operator= | ( | const ROW & | source | ) |

Definition at line 216 of file ocrrow.cpp.

{
this->ELIST_LINK::operator= (source);
kerning = source.kerning;
spacing = source.spacing;
xheight = source.xheight;
bodysize = source.bodysize;
ascrise = source.ascrise;
descdrop = source.descdrop;
if (!words.empty ())
words.clear ();
baseline = source.baseline; //QSPLINES must do =
bound_box = source.bound_box;
has_drop_cap_ = source.has_drop_cap_;
lmargin_ = source.lmargin_;
rmargin_ = source.rmargin_;
para_ = source.para_;
return *this;
}

PARA* ROW::para | ( |  | ) | const

inline

Definition at line 112 of file ocrrow.h.

{
return para_;
}

void ROW::plot | ( | ScrollView * | window,
|  | ScrollView::Color | colour
| ) |  |

Definition at line 178 of file ocrrow.cpp.

{
WERD *word; //current word
WERD_IT it = &words; //words of ROW
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
word = it.data ();
word->plot (window, colour); //all in one colour
}
}

void ROW::plot | ( | ScrollView * | window | ) |

Definition at line 197 of file ocrrow.cpp.

{
WERD *word; //current word
WERD_IT it = &words; //words of ROW
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
word = it.data ();
word->plot (window); //in rainbow colours
}
}

void ROW::plot_baseline | ( | ScrollView * | window,
|  | ScrollView::Color | colour
| ) |  |

inline

Definition at line 131 of file ocrrow.h.

{ //colour to draw
//draw it
baseline.plot (window, colour);
}

void ROW::print | ( | FILE * | fp | ) |

Definition at line 157 of file ocrrow.cpp.

{
tprintf("Kerning= %d\n", kerning);
tprintf("Spacing= %d\n", spacing);
bound_box.print();
tprintf("Xheight= %f\n", xheight);
tprintf("Ascrise= %f\n", ascrise);
tprintf("Descdrop= %f\n", descdrop);
tprintf("has_drop_cap= %d\n", has_drop_cap_);
tprintf("lmargin= %d, rmargin= %d\n", lmargin_, rmargin_);
}

void ROW::recalc_bounding_box | ( |  | ) |

Definition at line 91 of file ocrrow.cpp.

{ //recalculate BB
WERD *word; //current word
WERD_IT it = &words; //words of ROW
inT16 left; //of word
inT16 prev_left; //old left
if (!it.empty ()) {
word = it.data ();
prev_left = word->bounding_box ().left ();
it.forward ();
while (!it.at_first ()) {
word = it.data ();
left = word->bounding_box ().left ();
if (left < prev_left) {
it.move_to_first ();
//words in BB order
it.sort (word_comparator);
break;
}
prev_left = left;
it.forward ();
}
}
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
word = it.data ();
if (it.at_first ())
word->set_flag (W_BOL, TRUE);
else
//not start of line
word->set_flag (W_BOL, FALSE);
if (it.at_last ())
word->set_flag (W_EOL, TRUE);
else
//not end of line
word->set_flag (W_EOL, FALSE);
//extend BB as reqd
bound_box += word->bounding_box ();
}
}

inT16 ROW::rmargin | ( |  | ) | const

inline

Definition at line 98 of file ocrrow.h.

{
return rmargin_;
}

void ROW::set_body_size | ( | float | new_size | ) |

inline

Definition at line 73 of file ocrrow.h.

{ // set body size
bodysize = new_size;
}

void ROW::set_has_drop_cap | ( | bool | has | ) |

inline

Definition at line 102 of file ocrrow.h.

{
has_drop_cap_ = has;
}

void ROW::set_lmargin | ( | inT16 | lmargin | ) |

inline

Definition at line 89 of file ocrrow.h.

{
lmargin_ = lmargin;
}

void ROW::set_para | ( | PARA * | p | ) |

inline

Definition at line 109 of file ocrrow.h.

{
para_ = p;
}

void ROW::set_rmargin | ( | inT16 | rmargin | ) |

inline

Definition at line 92 of file ocrrow.h.

{
rmargin_ = rmargin;
}

void ROW::set_x_height | ( | float | new_xheight | ) |

inline

Definition at line 64 of file ocrrow.h.

{ // set x height
xheight = new_xheight;
}

inT32 ROW::space | ( |  | ) | const

inline

Definition at line 76 of file ocrrow.h.

{ //return spacing
return spacing;
}

WERD_LIST* ROW::word_list | ( |  | ) |

inline

Definition at line 52 of file ocrrow.h.

{ //get words
return &words;
}

float ROW::x_height | ( |  | ) | const

inline

Definition at line 61 of file ocrrow.h.

{ //return x height
return xheight;
}

## Friends And Related Function Documentation

void tweak_row_baseline | ( | ROW * | ,
|  | double | ,
|  | double |
| ) |  |

friend

Definition at line 680 of file tordmain.cpp.

{
TBOX blob_box; //bounding box
C_BLOB *blob; //current blob
WERD *word; //current word
inT32 blob_count; //no of blobs
inT32 src_index; //source segment
inT32 dest_index; //destination segment
inT32 *xstarts; //spline segments
double *coeffs; //spline coeffs
float ydiff; //baseline error
float x_centre; //centre of blob
//words of row
WERD_IT word_it = row->word_list ();
C_BLOB_IT blob_it; //blob iterator
blob_count = 0;
for (word_it.mark_cycle_pt (); !word_it.cycled_list (); word_it.forward ()) {
word = word_it.data (); //current word
//get total blobs
blob_count += word->cblob_list ()->length ();
}
if (blob_count == 0)
return;
xstarts =
(inT32 *) alloc_mem ((blob_count + row->baseline.segments + 1) *
sizeof (inT32));
coeffs =
(double *) alloc_mem ((blob_count + row->baseline.segments) * 3 *
sizeof (double));
src_index = 0;
dest_index = 0;
xstarts[0] = row->baseline.xcoords[0];
for (word_it.mark_cycle_pt (); !word_it.cycled_list (); word_it.forward ()) {
word = word_it.data (); //current word
//blobs in word
blob_it.set_to_list (word->cblob_list ());
for (blob_it.mark_cycle_pt (); !blob_it.cycled_list ();
blob_it.forward ()) {
blob = blob_it.data ();
blob_box = blob->bounding_box ();
x_centre = (blob_box.left () + blob_box.right ()) / 2.0;
ydiff = blob_box.bottom () - row->base_line (x_centre);
if (ydiff < 0)
ydiff = -ydiff / row->x_height ();
else
ydiff = ydiff / row->x_height ();
if (ydiff < blshift_maxshift
&& blob_box.height () / row->x_height () > blshift_xfraction) {
if (xstarts[dest_index] >= x_centre)
xstarts[dest_index] = blob_box.left ();
coeffs[dest_index * 3] = 0;
coeffs[dest_index * 3 + 1] = 0;
coeffs[dest_index * 3 + 2] = blob_box.bottom ();
//shift it
dest_index++;
xstarts[dest_index] = blob_box.right () + 1;
}
else {
if (xstarts[dest_index] <= x_centre) {
while (row->baseline.xcoords[src_index + 1] <= x_centre
&& src_index < row->baseline.segments - 1) {
if (row->baseline.xcoords[src_index + 1] >
xstarts[dest_index]) {
coeffs[dest_index * 3] =
row->baseline.quadratics[src_index].a;
coeffs[dest_index * 3 + 1] =
row->baseline.quadratics[src_index].b;
coeffs[dest_index * 3 + 2] =
row->baseline.quadratics[src_index].c;
dest_index++;
xstarts[dest_index] =
row->baseline.xcoords[src_index + 1];
}
src_index++;
}
coeffs[dest_index * 3] =
row->baseline.quadratics[src_index].a;
coeffs[dest_index * 3 + 1] =
row->baseline.quadratics[src_index].b;
coeffs[dest_index * 3 + 2] =
row->baseline.quadratics[src_index].c;
dest_index++;
xstarts[dest_index] = row->baseline.xcoords[src_index + 1];
}
}
}
}
while (src_index < row->baseline.segments
&& row->baseline.xcoords[src_index + 1] <= xstarts[dest_index])
src_index++;
while (src_index < row->baseline.segments) {
coeffs[dest_index * 3] = row->baseline.quadratics[src_index].a;
coeffs[dest_index * 3 + 1] = row->baseline.quadratics[src_index].b;
coeffs[dest_index * 3 + 2] = row->baseline.quadratics[src_index].c;
dest_index++;
src_index++;
xstarts[dest_index] = row->baseline.xcoords[src_index];
}
//turn to spline
row->baseline = QSPLINE (dest_index, xstarts, coeffs);
free_mem(xstarts);
free_mem(coeffs);
}

The documentation for this class was generated from the following files:

- /mnt/data/src/tesseract-ocr/ccstruct/ocrrow.h
- /mnt/data/src/tesseract-ocr/ccstruct/ocrrow.cpp