20 #ifndef TESSERACT_TEXTORD_TABVECTOR_H_ 21 #define TESSERACT_TEXTORD_TABVECTOR_H_ 39 "Max fraction of mean blob width allowed for vertical gaps in vertical text");
41 "Fraction of box matches required to declare a line vertical");
79 static void CreateConstraint(
TabVector* vector,
bool is_top);
82 static bool CompatibleConstraints(TabConstraint_LIST* list1,
83 TabConstraint_LIST* list2);
87 static void MergeConstraints(TabConstraint_LIST* list1,
88 TabConstraint_LIST* list2);
92 static void ApplyConstraints(TabConstraint_LIST* constraints);
98 static void GetConstraints(TabConstraint_LIST* constraints,
99 int* y_min,
int* y_max);
128 int extended_start_y,
int extended_end_y,
129 BLOBNBOX_CLIST* good_points,
130 int* vertical_x,
int* vertical_y);
153 return extended_ymax_;
156 return extended_ymin_;
165 top_constraints_ = constraints;
168 bottom_constraints_ = constraints;
180 return intersects_other_lines_;
183 intersects_other_lines_ = value;
190 int height = endpt_.
y() - startpt_.
y();
192 return (y - startpt_.
y()) * (endpt_.
x() - startpt_.
x()) / height +
200 return std::min(other.endpt_.
y(), endpt_.
y()) -
201 std::max(other.startpt_.
y(), startpt_.
y());
205 return std::min(top_y, static_cast<int>(endpt_.
y())) - std::max(bottom_y, static_cast<int>(startpt_.
y()));
209 return std::min(top_y, extended_ymax_) - std::max(bottom_y, extended_ymin_);
236 return sort_key_ < other.sort_key_;
241 return partners_.empty();
246 return boxes_.length();
251 boxes_.shallow_clear();
256 int x = startpt_.
y();
257 startpt_.
set_y(startpt_.
x());
266 startpt_.
set_x(-startpt_.
x());
267 endpt_.
set_x(-endpt_.
x());
268 sort_key_ = -sort_key_;
282 return pt * vertical;
287 if (vertical.
y() != 0)
288 return (vertical.
x() * y +
sort_key) / vertical.
y();
297 return tv1->sort_key_ - tv2->sort_key_;
329 TabVector_LIST* vectors,
BlobGrid* grid);
349 void Print(
const char* prefix);
352 void Debug(
const char* prefix);
373 bool Fit(
ICOORD vertical,
bool force_parallel);
413 bool needs_evaluation_;
415 bool intersects_other_lines_;
419 BLOBNBOX_CLIST boxes_;
421 TabVector_CLIST partners_;
424 TabConstraint_LIST* top_constraints_;
425 TabConstraint_LIST* bottom_constraints_;
430 #endif // TESSERACT_TEXTORD_TABVECTOR_H_
void set_endpt(const ICOORD &end)
void set_bottom_constraints(TabConstraint_LIST *constraints)
bool Fit(ICOORD vertical, bool force_parallel)
#define ELISTIZEH(CLASSNAME)
const ICOORD & startpt() const
double textord_tabvector_vertical_box_ratio
TabVector * GetSinglePartner()
void set_x(int16_t xin)
rewrite function
int16_t y() const
access_function
#define double_VAR_H(name, val, comment)
void Evaluate(const ICOORD &vertical, TabFind *finder)
bool IsLeftOf(const TabVector &other) const
void Debug(const char *prefix)
int extended_ymin() const
bool intersects_other_lines() const
void set_top_constraints(TabConstraint_LIST *constraints)
bool IsAPartner(const TabVector *other)
void Rotate(const FCOORD &rotation)
void AddPartner(TabVector *partner)
double textord_tabvector_vertical_gap_fraction
CLISTIZEH(STRING) CLISTIZE(STRING) namespace tesseract
int16_t x() const
access function
int ExtendedOverlap(int top_y, int bottom_y) const
#define ELIST2IZEH(CLASSNAME)
void SetupPartnerConstraints()
void ExtendToBox(BLOBNBOX *blob)
void MergeWith(const ICOORD &vertical, TabVector *other)
static int SortVectorsByKey(const void *v1, const void *v2)
int extended_ymax() const
static int SortKey(const ICOORD &vertical, int x, int y)
int VOverlap(const TabVector &other) const
static void MergeSimilarTabVectors(const ICOORD &vertical, TabVector_LIST *vectors, BlobGrid *grid)
static TabVector * FitVector(TabAlignment alignment, ICOORD vertical, int extended_start_y, int extended_end_y, BLOBNBOX_CLIST *good_points, int *vertical_x, int *vertical_y)
TabVector * VerticalTextlinePartner()
void set_startpt(const ICOORD &start)
void set_intersects_other_lines(bool value)
void FitAndEvaluateIfNeeded(const ICOORD &vertical, TabFind *finder)
void SetYStart(int start_y)
TabVector * ShallowCopy() const
bool SimilarTo(const ICOORD &vertical, const TabVector &other, BlobGrid *grid) const
void set_y(int16_t yin)
rewrite function
void Display(ScrollView *tab_win)
void Print(const char *prefix)
TabVector_CLIST * partners()
static int XAtY(const ICOORD &vertical, int sort_key, int y)
const ICOORD & endpt() const
int VOverlap(int top_y, int bottom_y) const