tesseract  5.0.0-alpha-619-ge9db
tesseract::AlignedBlobParams Struct Reference

#include <alignedblob.h>

Public Member Functions

 AlignedBlobParams (int vertical_x, int vertical_y, int height, int v_gap_multiple, int min_gutter_width, int resolution, TabAlignment alignment0)
 
 AlignedBlobParams (int vertical_x, int vertical_y, int width)
 
void set_vertical (int vertical_x, int vertical_y)
 

Public Attributes

double gutter_fraction
 
bool right_tab
 
bool ragged
 
TabAlignment alignment
 
TabType confirmed_type
 
int max_v_gap
 
int min_gutter
 
int l_align_tolerance
 
int r_align_tolerance
 
int min_points
 
int min_length
 
ICOORD vertical
 

Detailed Description

Definition at line 42 of file alignedblob.h.

Constructor & Destructor Documentation

◆ AlignedBlobParams() [1/2]

tesseract::AlignedBlobParams::AlignedBlobParams ( int  vertical_x,
int  vertical_y,
int  height,
int  v_gap_multiple,
int  min_gutter_width,
int  resolution,
TabAlignment  alignment0 
)

Definition at line 73 of file alignedblob.cpp.

77  : right_tab(align0 == TA_RIGHT_RAGGED || align0 == TA_RIGHT_ALIGNED),
78  ragged(align0 == TA_LEFT_RAGGED || align0 == TA_RIGHT_RAGGED),
79  alignment(align0),
81  min_length(0) {
82  // Set the tolerances according to the type of line sought.
83  // For tab search, these are based on the image resolution for most, or
84  // the height of the starting blob for the maximum vertical gap.
85  max_v_gap = height * v_gap_multiple;
86  if (ragged) {
87  // In the case of a ragged edge, we are much more generous with the
88  // inside alignment fraction, but also require a much bigger gutter.
90  if (alignment == TA_RIGHT_RAGGED) {
91  l_align_tolerance = static_cast<int>(resolution * kRaggedFraction + 0.5);
92  r_align_tolerance = static_cast<int>(resolution * kAlignedFraction + 0.5);
93  } else {
94  l_align_tolerance = static_cast<int>(resolution * kAlignedFraction + 0.5);
95  r_align_tolerance = static_cast<int>(resolution * kRaggedFraction + 0.5);
96  }
98  } else {
100  l_align_tolerance = static_cast<int>(resolution * kAlignedFraction + 0.5);
101  r_align_tolerance = static_cast<int>(resolution * kAlignedFraction + 0.5);
103  }
104  min_gutter = static_cast<int>(height * gutter_fraction + 0.5);
105  if (min_gutter < min_gutter_width)
106  min_gutter = min_gutter_width;
107  // Fit the vertical vector into an ICOORD, which is 16 bit.
108  set_vertical(vertical_x, vertical_y);
109 }

◆ AlignedBlobParams() [2/2]

tesseract::AlignedBlobParams::AlignedBlobParams ( int  vertical_x,
int  vertical_y,
int  width 
)

Definition at line 114 of file alignedblob.cpp.

116  : gutter_fraction(0.0),
117  right_tab(false),
118  ragged(false),
123  min_points(1),
125  // Compute threshold for left and right alignment.
126  l_align_tolerance = std::max(kVLineAlignment, width);
127  r_align_tolerance = std::max(kVLineAlignment, width);
128 
129  // Fit the vertical vector into an ICOORD, which is 16 bit.
130  set_vertical(vertical_x, vertical_y);
131 }

Member Function Documentation

◆ set_vertical()

void tesseract::AlignedBlobParams::set_vertical ( int  vertical_x,
int  vertical_y 
)

Definition at line 134 of file alignedblob.cpp.

134  {
135  int factor = 1;
136  if (vertical_y > INT16_MAX)
137  factor = vertical_y / INT16_MAX + 1;
138  vertical.set_x(vertical_x / factor);
139  vertical.set_y(vertical_y / factor);
140 }

Member Data Documentation

◆ alignment

TabAlignment tesseract::AlignedBlobParams::alignment

Definition at line 64 of file alignedblob.h.

◆ confirmed_type

TabType tesseract::AlignedBlobParams::confirmed_type

Definition at line 65 of file alignedblob.h.

◆ gutter_fraction

double tesseract::AlignedBlobParams::gutter_fraction

Definition at line 61 of file alignedblob.h.

◆ l_align_tolerance

int tesseract::AlignedBlobParams::l_align_tolerance

Definition at line 69 of file alignedblob.h.

◆ max_v_gap

int tesseract::AlignedBlobParams::max_v_gap

Definition at line 66 of file alignedblob.h.

◆ min_gutter

int tesseract::AlignedBlobParams::min_gutter

Definition at line 67 of file alignedblob.h.

◆ min_length

int tesseract::AlignedBlobParams::min_length

Definition at line 73 of file alignedblob.h.

◆ min_points

int tesseract::AlignedBlobParams::min_points

Definition at line 72 of file alignedblob.h.

◆ r_align_tolerance

int tesseract::AlignedBlobParams::r_align_tolerance

Definition at line 70 of file alignedblob.h.

◆ ragged

bool tesseract::AlignedBlobParams::ragged

Definition at line 63 of file alignedblob.h.

◆ right_tab

bool tesseract::AlignedBlobParams::right_tab

Definition at line 62 of file alignedblob.h.

◆ vertical

ICOORD tesseract::AlignedBlobParams::vertical

Definition at line 75 of file alignedblob.h.


The documentation for this struct was generated from the following files:
tesseract::TA_LEFT_RAGGED
Definition: tabvector.h:46
ICOORD::set_x
void set_x(int16_t xin)
rewrite function
Definition: points.h:60
tesseract::kAlignedFraction
const double kAlignedFraction
Definition: alignedblob.cpp:38
tesseract::TA_SEPARATOR
Definition: tabvector.h:50
tesseract::AlignedBlobParams::min_gutter
int min_gutter
Definition: alignedblob.h:67
tesseract::AlignedBlobParams::min_points
int min_points
Definition: alignedblob.h:72
tesseract::TA_RIGHT_ALIGNED
Definition: tabvector.h:48
TT_CONFIRMED
Definition: blobbox.h:63
tesseract::kAlignedGapFraction
const double kAlignedGapFraction
Definition: alignedblob.cpp:42
ICOORD::set_y
void set_y(int16_t yin)
rewrite function
Definition: points.h:64
tesseract::kRaggedGapFraction
const double kRaggedGapFraction
Definition: alignedblob.cpp:44
tesseract::AlignedBlobParams::right_tab
bool right_tab
Definition: alignedblob.h:62
tesseract::kVLineMinLength
const int kVLineMinLength
Definition: alignedblob.cpp:56
tesseract::kVLineSearchSize
const int kVLineSearchSize
Definition: alignedblob.cpp:50
tesseract::AlignedBlobParams::set_vertical
void set_vertical(int vertical_x, int vertical_y)
Definition: alignedblob.cpp:134
tesseract::AlignedBlobParams::alignment
TabAlignment alignment
Definition: alignedblob.h:64
tesseract::kVLineGutter
const int kVLineGutter
Definition: alignedblob.cpp:48
tesseract::kRaggedFraction
const double kRaggedFraction
Definition: alignedblob.cpp:40
tesseract::kMinRaggedTabs
const int kMinRaggedTabs
Definition: alignedblob.cpp:52
tesseract::AlignedBlobParams::confirmed_type
TabType confirmed_type
Definition: alignedblob.h:65
tesseract::kVLineAlignment
const int kVLineAlignment
Definition: alignedblob.cpp:46
tesseract::AlignedBlobParams::gutter_fraction
double gutter_fraction
Definition: alignedblob.h:61
tesseract::AlignedBlobParams::r_align_tolerance
int r_align_tolerance
Definition: alignedblob.h:70
tesseract::AlignedBlobParams::ragged
bool ragged
Definition: alignedblob.h:63
TT_VLINE
Definition: blobbox.h:64
tesseract::AlignedBlobParams::min_length
int min_length
Definition: alignedblob.h:73
tesseract::kMinAlignedTabs
const int kMinAlignedTabs
Definition: alignedblob.cpp:54
tesseract::TA_RIGHT_RAGGED
Definition: tabvector.h:49
tesseract::AlignedBlobParams::max_v_gap
int max_v_gap
Definition: alignedblob.h:66
tesseract::AlignedBlobParams::vertical
ICOORD vertical
Definition: alignedblob.h:75
tesseract::AlignedBlobParams::l_align_tolerance
int l_align_tolerance
Definition: alignedblob.h:69