tesseract  4.1.0
tesseract::TabVector Class Reference

#include <tabvector.h>

Inheritance diagram for tesseract::TabVector:
ELIST2_LINK

Public Member Functions

 TabVector ()=default
 
 ~TabVector ()=default
 
 TabVector (const TabVector &src, TabAlignment alignment, const ICOORD &vertical_skew, BLOBNBOX *blob)
 
TabVectorShallowCopy () const
 
const ICOORDstartpt () const
 
const ICOORDendpt () const
 
int extended_ymax () const
 
int extended_ymin () const
 
int sort_key () const
 
int mean_width () const
 
void set_top_constraints (TabConstraint_LIST *constraints)
 
void set_bottom_constraints (TabConstraint_LIST *constraints)
 
TabVector_CLIST * partners ()
 
void set_startpt (const ICOORD &start)
 
void set_endpt (const ICOORD &end)
 
bool intersects_other_lines () const
 
void set_intersects_other_lines (bool value)
 
int XAtY (int y) const
 
int VOverlap (const TabVector &other) const
 
int VOverlap (int top_y, int bottom_y) const
 
int ExtendedOverlap (int top_y, int bottom_y) const
 
bool IsLeftTab () const
 
bool IsRightTab () const
 
bool IsSeparator () const
 
bool IsCenterTab () const
 
bool IsRagged () const
 
bool IsLeftOf (const TabVector &other) const
 
bool Partnerless ()
 
int BoxCount ()
 
void Freeze ()
 
void XYFlip ()
 
void ReflectInYAxis ()
 
void ExtendToBox (BLOBNBOX *blob)
 
void SetYStart (int start_y)
 
void SetYEnd (int end_y)
 
void Rotate (const FCOORD &rotation)
 
void SetupConstraints ()
 
void SetupPartnerConstraints ()
 
void SetupPartnerConstraints (TabVector *partner)
 
void ApplyConstraints ()
 
bool SimilarTo (const ICOORD &vertical, const TabVector &other, BlobGrid *grid) const
 
void MergeWith (const ICOORD &vertical, TabVector *other)
 
void AddPartner (TabVector *partner)
 
bool IsAPartner (const TabVector *other)
 
void Print (const char *prefix)
 
void Debug (const char *prefix)
 
void Display (ScrollView *tab_win)
 
void FitAndEvaluateIfNeeded (const ICOORD &vertical, TabFind *finder)
 
void Evaluate (const ICOORD &vertical, TabFind *finder)
 
bool Fit (ICOORD vertical, bool force_parallel)
 
TabVectorVerticalTextlinePartner ()
 
TabVectorGetSinglePartner ()
 
- Public Member Functions inherited from ELIST2_LINK
 ELIST2_LINK ()
 
 ELIST2_LINK (const ELIST2_LINK &)
 
void operator= (const ELIST2_LINK &)
 

Static Public Member Functions

static TabVectorFitVector (TabAlignment alignment, ICOORD vertical, int extended_start_y, int extended_end_y, BLOBNBOX_CLIST *good_points, int *vertical_x, int *vertical_y)
 
static int SortKey (const ICOORD &vertical, int x, int y)
 
static int XAtY (const ICOORD &vertical, int sort_key, int y)
 
static int SortVectorsByKey (const void *v1, const void *v2)
 
static void MergeSimilarTabVectors (const ICOORD &vertical, TabVector_LIST *vectors, BlobGrid *grid)
 

Detailed Description

Definition at line 112 of file tabvector.h.

Constructor & Destructor Documentation

tesseract::TabVector::TabVector ( )
default
tesseract::TabVector::~TabVector ( )
default
tesseract::TabVector::TabVector ( const TabVector src,
TabAlignment  alignment,
const ICOORD vertical_skew,
BLOBNBOX blob 
)

Definition at line 198 of file tabvector.cpp.

200  : extended_ymin_(src.extended_ymin_), extended_ymax_(src.extended_ymax_),
201  sort_key_(0), percent_score_(0), mean_width_(0),
202  needs_refit_(true), needs_evaluation_(true), intersects_other_lines_(false),
203  alignment_(alignment),
204  top_constraints_(nullptr), bottom_constraints_(nullptr) {
205  BLOBNBOX_C_IT it(&boxes_);
206  it.add_to_end(blob);
207  TBOX box = blob->bounding_box();
208  if (IsLeftTab()) {
209  startpt_ = box.botleft();
210  endpt_ = box.topleft();
211  } else {
212  startpt_ = box.botright();
213  endpt_ = box.topright();
214  }
215  sort_key_ = SortKey(vertical_skew,
216  (startpt_.x() + endpt_.x()) / 2,
217  (startpt_.y() + endpt_.y()) / 2);
218  if (textord_debug_tabfind > 3)
219  Print("Constructed a new tab vector:");
220 }
Definition: rect.h:34
bool IsLeftTab() const
Definition: tabvector.h:213
void Print(const char *prefix)
Definition: tabvector.cpp:519
const TBOX & bounding_box() const
Definition: blobbox.h:230
int16_t y() const
access_function
Definition: points.h:56
const ICOORD & botleft() const
Definition: rect.h:92
ICOORD topleft() const
Definition: rect.h:100
static int SortKey(const ICOORD &vertical, int x, int y)
Definition: tabvector.h:280
ICOORD botright() const
Definition: rect.h:96
const ICOORD & topright() const
Definition: rect.h:104
int16_t x() const
access function
Definition: points.h:52
int textord_debug_tabfind
Definition: alignedblob.cpp:27

Member Function Documentation

void tesseract::TabVector::AddPartner ( TabVector partner)

Definition at line 486 of file tabvector.cpp.

486  {
487  if (IsSeparator() || partner->IsSeparator())
488  return;
489  TabVector_C_IT it(&partners_);
490  if (!it.empty()) {
491  it.move_to_last();
492  if (it.data() == partner)
493  return;
494  }
495  it.add_after_then_move(partner);
496 }
bool IsSeparator() const
Definition: tabvector.h:221
void tesseract::TabVector::ApplyConstraints ( )

Definition at line 347 of file tabvector.cpp.

347  {
348  if (top_constraints_ != nullptr)
349  TabConstraint::ApplyConstraints(top_constraints_);
350  if (bottom_constraints_ != nullptr)
351  TabConstraint::ApplyConstraints(bottom_constraints_);
352 }
static void ApplyConstraints(TabConstraint_LIST *constraints)
Definition: tabvector.cpp:116
int tesseract::TabVector::BoxCount ( )
inline

Definition at line 245 of file tabvector.h.

245  {
246  return boxes_.length();
247  }
void tesseract::TabVector::Debug ( const char *  prefix)

Definition at line 529 of file tabvector.cpp.

529  {
530  Print(prefix);
531  BLOBNBOX_C_IT it(&boxes_);
532  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
533  BLOBNBOX* bbox = it.data();
534  const TBOX& box = bbox->bounding_box();
535  tprintf("Box at (%d,%d)->(%d,%d)\n",
536  box.left(), box.bottom(), box.right(), box.top());
537  }
538 }
int16_t top() const
Definition: rect.h:58
Definition: rect.h:34
void Print(const char *prefix)
Definition: tabvector.cpp:519
const TBOX & bounding_box() const
Definition: blobbox.h:230
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:36
int16_t right() const
Definition: rect.h:79
int16_t bottom() const
Definition: rect.h:65
int16_t left() const
Definition: rect.h:72
void tesseract::TabVector::Display ( ScrollView tab_win)

Definition at line 541 of file tabvector.cpp.

541  {
542 #ifndef GRAPHICS_DISABLED
544  tab_win->Pen(ScrollView::BLUE);
545  else if (alignment_ == TA_LEFT_ALIGNED)
546  tab_win->Pen(ScrollView::LIME_GREEN);
547  else if (alignment_ == TA_LEFT_RAGGED)
548  tab_win->Pen(ScrollView::DARK_GREEN);
549  else if (alignment_ == TA_RIGHT_ALIGNED)
550  tab_win->Pen(ScrollView::PINK);
551  else if (alignment_ == TA_RIGHT_RAGGED)
552  tab_win->Pen(ScrollView::CORAL);
553  else
554  tab_win->Pen(ScrollView::WHITE);
555  tab_win->Line(startpt_.x(), startpt_.y(), endpt_.x(), endpt_.y());
556  tab_win->Pen(ScrollView::GREY);
557  tab_win->Line(startpt_.x(), startpt_.y(), startpt_.x(), extended_ymin_);
558  tab_win->Line(endpt_.x(), extended_ymax_, endpt_.x(), endpt_.y());
559  char score_buf[64];
560  snprintf(score_buf, sizeof(score_buf), "%d", percent_score_);
561  tab_win->TextAttributes("Times", 50, false, false, false);
562  tab_win->Text(startpt_.x(), startpt_.y(), score_buf);
563 #endif
564 }
void Text(int x, int y, const char *mystring)
Definition: scrollview.cpp:652
int16_t y() const
access_function
Definition: points.h:56
void TextAttributes(const char *font, int pixel_size, bool bold, bool italic, bool underlined)
Definition: scrollview.cpp:635
bool textord_debug_printable
Definition: alignedblob.cpp:33
void Pen(Color color)
Definition: scrollview.cpp:719
int16_t x() const
access function
Definition: points.h:52
void Line(int x1, int y1, int x2, int y2)
Definition: scrollview.cpp:532
const ICOORD& tesseract::TabVector::endpt ( ) const
inline

Definition at line 149 of file tabvector.h.

149  {
150  return endpt_;
151  }
void tesseract::TabVector::Evaluate ( const ICOORD vertical,
TabFind finder 
)

Definition at line 581 of file tabvector.cpp.

581  {
582  bool debug = false;
583  needs_evaluation_ = false;
584  int length = endpt_.y() - startpt_.y();
585  if (length == 0 || boxes_.empty()) {
586  percent_score_ = 0;
587  Print("Zero length in evaluate");
588  return;
589  }
590  // Compute the mean box height.
591  BLOBNBOX_C_IT it(&boxes_);
592  int mean_height = 0;
593  int height_count = 0;
594  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
595  BLOBNBOX* bbox = it.data();
596  const TBOX& box = bbox->bounding_box();
597  int height = box.height();
598  mean_height += height;
599  ++height_count;
600  }
601  if (height_count > 0) mean_height /= height_count;
602  int max_gutter = kGutterMultiple * mean_height;
603  if (IsRagged()) {
604  // Ragged edges face a tougher test in that the gap must always be within
605  // the height of the blob.
606  max_gutter = kGutterToNeighbourRatio * mean_height;
607  }
608 
609  STATS gutters(0, max_gutter + 1);
610  // Evaluate the boxes for their goodness, calculating the coverage as we go.
611  // Remove boxes that are not good and shorten the list to the first and
612  // last good boxes.
613  int num_deleted_boxes = 0;
614  bool text_on_image = false;
615  int good_length = 0;
616  const TBOX* prev_good_box = nullptr;
617  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
618  BLOBNBOX* bbox = it.data();
619  const TBOX& box = bbox->bounding_box();
620  int mid_y = (box.top() + box.bottom()) / 2;
621  if (TabFind::WithinTestRegion(2, XAtY(box.bottom()), box.bottom())) {
622  if (!debug) {
623  tprintf("After already deleting %d boxes, ", num_deleted_boxes);
624  Print("Starting evaluation");
625  }
626  debug = true;
627  }
628  // A good box is one where the nearest neighbour on the inside is closer
629  // than half the distance to the nearest neighbour on the outside
630  // (of the putative column).
631  bool left = IsLeftTab();
632  int tab_x = XAtY(mid_y);
633  int gutter_width;
634  int neighbour_gap;
635  finder->GutterWidthAndNeighbourGap(tab_x, mean_height, max_gutter, left,
636  bbox, &gutter_width, &neighbour_gap);
637  if (debug) {
638  tprintf("Box (%d,%d)->(%d,%d) has gutter %d, ndist %d\n",
639  box.left(), box.bottom(), box.right(), box.top(),
640  gutter_width, neighbour_gap);
641  }
642  // Now we can make the test.
643  if (neighbour_gap * kGutterToNeighbourRatio <= gutter_width) {
644  // A good box contributes its height to the good_length.
645  good_length += box.top() - box.bottom();
646  gutters.add(gutter_width, 1);
647  // Two good boxes together contribute the gap between them
648  // to the good_length as well, as long as the gap is not
649  // too big.
650  if (prev_good_box != nullptr) {
651  int vertical_gap = box.bottom() - prev_good_box->top();
652  double size1 = sqrt(static_cast<double>(prev_good_box->area()));
653  double size2 = sqrt(static_cast<double>(box.area()));
654  if (vertical_gap < kMaxFillinMultiple * std::min(size1, size2))
655  good_length += vertical_gap;
656  if (debug) {
657  tprintf("Box and prev good, gap=%d, target %g, goodlength=%d\n",
658  vertical_gap, kMaxFillinMultiple * std::min(size1, size2),
659  good_length);
660  }
661  } else {
662  // Adjust the start to the first good box.
663  SetYStart(box.bottom());
664  }
665  prev_good_box = &box;
666  if (bbox->flow() == BTFT_TEXT_ON_IMAGE)
667  text_on_image = true;
668  } else {
669  // Get rid of boxes that are not good.
670  if (debug) {
671  tprintf("Bad Box (%d,%d)->(%d,%d) with gutter %d, ndist %d\n",
672  box.left(), box.bottom(), box.right(), box.top(),
673  gutter_width, neighbour_gap);
674  }
675  it.extract();
676  ++num_deleted_boxes;
677  }
678  }
679  if (debug) {
680  Print("Evaluating:");
681  }
682  // If there are any good boxes, do it again, except this time get rid of
683  // boxes that have a gutter that is a small fraction of the mean gutter.
684  // This filters out ends that run into a coincidental gap in the text.
685  int search_top = endpt_.y();
686  int search_bottom = startpt_.y();
687  int median_gutter = IntCastRounded(gutters.median());
688  if (gutters.get_total() > 0) {
689  prev_good_box = nullptr;
690  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
691  BLOBNBOX* bbox = it.data();
692  const TBOX& box = bbox->bounding_box();
693  int mid_y = (box.top() + box.bottom()) / 2;
694  // A good box is one where the gutter width is at least some constant
695  // fraction of the mean gutter width.
696  bool left = IsLeftTab();
697  int tab_x = XAtY(mid_y);
698  int max_gutter = kGutterMultiple * mean_height;
699  if (IsRagged()) {
700  // Ragged edges face a tougher test in that the gap must always be
701  // within the height of the blob.
702  max_gutter = kGutterToNeighbourRatio * mean_height;
703  }
704  int gutter_width;
705  int neighbour_gap;
706  finder->GutterWidthAndNeighbourGap(tab_x, mean_height, max_gutter, left,
707  bbox, &gutter_width, &neighbour_gap);
708  // Now we can make the test.
709  if (gutter_width >= median_gutter * kMinGutterFraction) {
710  if (prev_good_box == nullptr) {
711  // Adjust the start to the first good box.
712  SetYStart(box.bottom());
713  search_bottom = box.top();
714  }
715  prev_good_box = &box;
716  search_top = box.bottom();
717  } else {
718  // Get rid of boxes that are not good.
719  if (debug) {
720  tprintf("Bad Box (%d,%d)->(%d,%d) with gutter %d, mean gutter %d\n",
721  box.left(), box.bottom(), box.right(), box.top(),
722  gutter_width, median_gutter);
723  }
724  it.extract();
725  ++num_deleted_boxes;
726  }
727  }
728  }
729  // If there has been a good box, adjust the end.
730  if (prev_good_box != nullptr) {
731  SetYEnd(prev_good_box->top());
732  // Compute the percentage of the vector that is occupied by good boxes.
733  int length = endpt_.y() - startpt_.y();
734  percent_score_ = 100 * good_length / length;
735  if (num_deleted_boxes > 0) {
736  needs_refit_ = true;
737  FitAndEvaluateIfNeeded(vertical, finder);
738  if (boxes_.empty())
739  return;
740  }
741  // Test the gutter over the whole vector, instead of just at the boxes.
742  int required_shift;
743  if (search_bottom > search_top) {
744  search_bottom = startpt_.y();
745  search_top = endpt_.y();
746  }
747  double min_gutter_width = kLineCountReciprocal / boxes_.length();
748  min_gutter_width += IsRagged() ? kMinRaggedGutter : kMinAlignedGutter;
749  min_gutter_width *= mean_height;
750  int max_gutter_width = IntCastRounded(min_gutter_width) + 1;
751  if (median_gutter > max_gutter_width)
752  max_gutter_width = median_gutter;
753  int gutter_width = finder->GutterWidth(search_bottom, search_top, *this,
754  text_on_image, max_gutter_width,
755  &required_shift);
756  if (gutter_width < min_gutter_width) {
757  if (debug) {
758  tprintf("Rejecting bad tab Vector with %d gutter vs %g min\n",
759  gutter_width, min_gutter_width);
760  }
761  boxes_.shallow_clear();
762  percent_score_ = 0;
763  } else if (debug) {
764  tprintf("Final gutter %d, vs limit of %g, required shift = %d\n",
765  gutter_width, min_gutter_width, required_shift);
766  }
767  } else {
768  // There are no good boxes left, so score is 0.
769  percent_score_ = 0;
770  }
771 
772  if (debug) {
773  Print("Evaluation complete:");
774  }
775 }
int IntCastRounded(double x)
Definition: helpers.h:175
int32_t area() const
Definition: rect.h:122
int16_t top() const
Definition: rect.h:58
Definition: rect.h:34
void FitAndEvaluateIfNeeded(const ICOORD &vertical, TabFind *finder)
Definition: tabvector.cpp:567
bool IsLeftTab() const
Definition: tabvector.h:213
const double kMinGutterFraction
Definition: tabvector.cpp:46
void Print(const char *prefix)
Definition: tabvector.cpp:519
const TBOX & bounding_box() const
Definition: blobbox.h:230
int16_t y() const
access_function
Definition: points.h:56
BlobTextFlowType flow() const
Definition: blobbox.h:295
const int kGutterMultiple
Definition: tabvector.cpp:35
const double kMinRaggedGutter
Definition: tabvector.cpp:52
int16_t height() const
Definition: rect.h:108
void SetYEnd(int end_y)
Definition: tabvector.cpp:269
const int kMaxFillinMultiple
Definition: tabvector.cpp:44
const double kLineCountReciprocal
Definition: tabvector.cpp:48
void SetYStart(int start_y)
Definition: tabvector.cpp:264
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:36
int16_t right() const
Definition: rect.h:79
int16_t bottom() const
Definition: rect.h:65
int XAtY(int y) const
Definition: tabvector.h:189
int16_t left() const
Definition: rect.h:72
bool IsRagged() const
Definition: tabvector.h:229
const double kMinAlignedGutter
Definition: tabvector.cpp:50
const int kGutterToNeighbourRatio
Definition: tabvector.cpp:37
Definition: statistc.h:31
static bool WithinTestRegion(int detail_level, int x, int y)
int tesseract::TabVector::extended_ymax ( ) const
inline

Definition at line 152 of file tabvector.h.

152  {
153  return extended_ymax_;
154  }
int tesseract::TabVector::extended_ymin ( ) const
inline

Definition at line 155 of file tabvector.h.

155  {
156  return extended_ymin_;
157  }
int tesseract::TabVector::ExtendedOverlap ( int  top_y,
int  bottom_y 
) const
inline

Definition at line 208 of file tabvector.h.

208  {
209  return std::min(top_y, extended_ymax_) - std::max(bottom_y, extended_ymin_);
210  }
void tesseract::TabVector::ExtendToBox ( BLOBNBOX blob)

Definition at line 240 of file tabvector.cpp.

240  {
241  TBOX new_box = new_blob->bounding_box();
242  BLOBNBOX_C_IT it(&boxes_);
243  if (!it.empty()) {
244  BLOBNBOX* blob = it.data();
245  TBOX box = blob->bounding_box();
246  while (!it.at_last() && box.top() <= new_box.top()) {
247  if (blob == new_blob)
248  return; // We have it already.
249  it.forward();
250  blob = it.data();
251  box = blob->bounding_box();
252  }
253  if (box.top() >= new_box.top()) {
254  it.add_before_stay_put(new_blob);
255  needs_refit_ = true;
256  return;
257  }
258  }
259  needs_refit_ = true;
260  it.add_after_stay_put(new_blob);
261 }
int16_t top() const
Definition: rect.h:58
Definition: rect.h:34
const TBOX & bounding_box() const
Definition: blobbox.h:230
bool tesseract::TabVector::Fit ( ICOORD  vertical,
bool  force_parallel 
)

Definition at line 782 of file tabvector.cpp.

782  {
783  needs_refit_ = false;
784  if (boxes_.empty()) {
785  // Don't refit something with no boxes, as that only happens
786  // in Evaluate, and we don't want to end up with a zero vector.
787  if (!force_parallel)
788  return false;
789  // If we are forcing parallel, then we just need to set the sort_key_.
790  ICOORD midpt = startpt_;
791  midpt += endpt_;
792  midpt /= 2;
793  sort_key_ = SortKey(vertical, midpt.x(), midpt.y());
794  return startpt_.y() != endpt_.y();
795  }
796  if (!force_parallel && !IsRagged()) {
797  // Use a fitted line as the vertical.
798  DetLineFit linepoints;
799  BLOBNBOX_C_IT it(&boxes_);
800  // Fit a line to all the boxes in the list.
801  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
802  BLOBNBOX* bbox = it.data();
803  const TBOX& box = bbox->bounding_box();
804  int x1 = IsRightTab() ? box.right() : box.left();
805  ICOORD boxpt(x1, box.bottom());
806  linepoints.Add(boxpt);
807  if (it.at_last()) {
808  ICOORD top_pt(x1, box.top());
809  linepoints.Add(top_pt);
810  }
811  }
812  linepoints.Fit(&startpt_, &endpt_);
813  if (startpt_.y() != endpt_.y()) {
814  vertical = endpt_;
815  vertical -= startpt_;
816  }
817  }
818  int start_y = startpt_.y();
819  int end_y = endpt_.y();
820  sort_key_ = IsLeftTab() ? INT32_MAX : -INT32_MAX;
821  BLOBNBOX_C_IT it(&boxes_);
822  // Choose a line parallel to the vertical such that all boxes are on the
823  // correct side of it.
824  mean_width_ = 0;
825  int width_count = 0;
826  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
827  BLOBNBOX* bbox = it.data();
828  const TBOX& box = bbox->bounding_box();
829  mean_width_ += box.width();
830  ++width_count;
831  int x1 = IsRightTab() ? box.right() : box.left();
832  // Test both the bottom and the top, as one will be more extreme, depending
833  // on the direction of skew.
834  int bottom_y = box.bottom();
835  int top_y = box.top();
836  int key = SortKey(vertical, x1, bottom_y);
837  if (IsLeftTab() == (key < sort_key_)) {
838  sort_key_ = key;
839  startpt_ = ICOORD(x1, bottom_y);
840  }
841  key = SortKey(vertical, x1, top_y);
842  if (IsLeftTab() == (key < sort_key_)) {
843  sort_key_ = key;
844  startpt_ = ICOORD(x1, top_y);
845  }
846  if (it.at_first())
847  start_y = bottom_y;
848  if (it.at_last())
849  end_y = top_y;
850  }
851  if (width_count > 0) {
852  mean_width_ = (mean_width_ + width_count - 1) / width_count;
853  }
854  endpt_ = startpt_ + vertical;
855  needs_evaluation_ = true;
856  if (start_y != end_y) {
857  // Set the ends of the vector to fully include the first and last blobs.
858  startpt_.set_x(XAtY(vertical, sort_key_, start_y));
859  startpt_.set_y(start_y);
860  endpt_.set_x(XAtY(vertical, sort_key_, end_y));
861  endpt_.set_y(end_y);
862  return true;
863  }
864  return false;
865 }
int16_t top() const
Definition: rect.h:58
Definition: rect.h:34
void set_x(int16_t xin)
rewrite function
Definition: points.h:61
bool IsLeftTab() const
Definition: tabvector.h:213
integer coordinate
Definition: points.h:31
const TBOX & bounding_box() const
Definition: blobbox.h:230
int16_t y() const
access_function
Definition: points.h:56
void set_y(int16_t yin)
rewrite function
Definition: points.h:65
static int SortKey(const ICOORD &vertical, int x, int y)
Definition: tabvector.h:280
int16_t x() const
access function
Definition: points.h:52
int16_t width() const
Definition: rect.h:115
int16_t right() const
Definition: rect.h:79
int16_t bottom() const
Definition: rect.h:65
int XAtY(int y) const
Definition: tabvector.h:189
int16_t left() const
Definition: rect.h:72
bool IsRagged() const
Definition: tabvector.h:229
bool IsRightTab() const
Definition: tabvector.h:217
void tesseract::TabVector::FitAndEvaluateIfNeeded ( const ICOORD vertical,
TabFind finder 
)

Definition at line 567 of file tabvector.cpp.

568  {
569  if (needs_refit_)
570  Fit(vertical, true);
571  if (needs_evaluation_)
572  Evaluate(vertical, finder);
573 }
void Evaluate(const ICOORD &vertical, TabFind *finder)
Definition: tabvector.cpp:581
bool Fit(ICOORD vertical, bool force_parallel)
Definition: tabvector.cpp:782
TabVector * tesseract::TabVector::FitVector ( TabAlignment  alignment,
ICOORD  vertical,
int  extended_start_y,
int  extended_end_y,
BLOBNBOX_CLIST *  good_points,
int *  vertical_x,
int *  vertical_y 
)
static

Definition at line 176 of file tabvector.cpp.

179  {
180  auto* vector = new TabVector(extended_start_y, extended_end_y,
181  alignment, good_points);
182  if (!vector->Fit(vertical, false)) {
183  delete vector;
184  return nullptr;
185  }
186  if (!vector->IsRagged()) {
187  vertical = vector->endpt_ - vector->startpt_;
188  int weight = vector->BoxCount();
189  *vertical_x += vertical.x() * weight;
190  *vertical_y += vertical.y() * weight;
191  }
192  return vector;
193 }
int16_t y() const
access_function
Definition: points.h:56
int16_t x() const
access function
Definition: points.h:52
void tesseract::TabVector::Freeze ( )
inline

Definition at line 250 of file tabvector.h.

250  {
251  boxes_.shallow_clear();
252  }
TabVector * tesseract::TabVector::GetSinglePartner ( )

Definition at line 868 of file tabvector.cpp.

868  {
869  if (!partners_.singleton())
870  return nullptr;
871  TabVector_C_IT partner_it(&partners_);
872  TabVector* partner = partner_it.data();
873  return partner;
874 }
bool tesseract::TabVector::intersects_other_lines ( ) const
inline

Definition at line 179 of file tabvector.h.

179  {
180  return intersects_other_lines_;
181  }
bool tesseract::TabVector::IsAPartner ( const TabVector other)

Definition at line 499 of file tabvector.cpp.

499  {
500  TabVector_C_IT it(&partners_);
501  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
502  if (it.data() == other)
503  return true;
504  }
505  return false;
506 }
bool tesseract::TabVector::IsCenterTab ( ) const
inline

Definition at line 225 of file tabvector.h.

225  {
226  return alignment_ == TA_CENTER_JUSTIFIED;
227  }
bool tesseract::TabVector::IsLeftOf ( const TabVector other) const
inline

Definition at line 235 of file tabvector.h.

235  {
236  return sort_key_ < other.sort_key_;
237  }
bool tesseract::TabVector::IsLeftTab ( ) const
inline

Definition at line 213 of file tabvector.h.

213  {
214  return alignment_ == TA_LEFT_ALIGNED || alignment_ == TA_LEFT_RAGGED;
215  }
bool tesseract::TabVector::IsRagged ( ) const
inline

Definition at line 229 of file tabvector.h.

229  {
230  return alignment_ == TA_LEFT_RAGGED || alignment_ == TA_RIGHT_RAGGED;
231  }
bool tesseract::TabVector::IsRightTab ( ) const
inline

Definition at line 217 of file tabvector.h.

217  {
218  return alignment_ == TA_RIGHT_ALIGNED || alignment_ == TA_RIGHT_RAGGED;
219  }
bool tesseract::TabVector::IsSeparator ( ) const
inline

Definition at line 221 of file tabvector.h.

221  {
222  return alignment_ == TA_SEPARATOR;
223  }
int tesseract::TabVector::mean_width ( ) const
inline

Definition at line 161 of file tabvector.h.

161  {
162  return mean_width_;
163  }
void tesseract::TabVector::MergeSimilarTabVectors ( const ICOORD vertical,
TabVector_LIST *  vectors,
BlobGrid grid 
)
static

Definition at line 355 of file tabvector.cpp.

357  {
358  TabVector_IT it1(vectors);
359  for (it1.mark_cycle_pt(); !it1.cycled_list(); it1.forward()) {
360  TabVector* v1 = it1.data();
361  TabVector_IT it2(it1);
362  for (it2.forward(); !it2.at_first(); it2.forward()) {
363  TabVector* v2 = it2.data();
364  if (v2->SimilarTo(vertical, *v1, grid)) {
365  // Merge into the forward one, in case the combined vector now
366  // overlaps one in between.
367  if (textord_debug_tabfind) {
368  v2->Print("Merging");
369  v1->Print("by deleting");
370  }
371  v2->MergeWith(vertical, it1.extract());
372  if (textord_debug_tabfind) {
373  v2->Print("Producing");
374  }
375  ICOORD merged_vector = v2->endpt();
376  merged_vector -= v2->startpt();
377  if (textord_debug_tabfind && abs(merged_vector.x()) > 100) {
378  v2->Print("Garbage result of merge?");
379  }
380  break;
381  }
382  }
383  }
384 }
integer coordinate
Definition: points.h:31
int16_t x() const
access function
Definition: points.h:52
int textord_debug_tabfind
Definition: alignedblob.cpp:27
void tesseract::TabVector::MergeWith ( const ICOORD vertical,
TabVector other 
)

Definition at line 452 of file tabvector.cpp.

452  {
453  extended_ymin_ = std::min(extended_ymin_, other->extended_ymin_);
454  extended_ymax_ = std::max(extended_ymax_, other->extended_ymax_);
455  if (other->IsRagged()) {
456  alignment_ = other->alignment_;
457  }
458  // Merge sort the two lists of boxes.
459  BLOBNBOX_C_IT it1(&boxes_);
460  BLOBNBOX_C_IT it2(&other->boxes_);
461  while (!it2.empty()) {
462  BLOBNBOX* bbox2 = it2.extract();
463  it2.forward();
464  TBOX box2 = bbox2->bounding_box();
465  BLOBNBOX* bbox1 = it1.data();
466  TBOX box1 = bbox1->bounding_box();
467  while (box1.bottom() < box2.bottom() && !it1.at_last()) {
468  it1.forward();
469  bbox1 = it1.data();
470  box1 = bbox1->bounding_box();
471  }
472  if (box1.bottom() < box2.bottom()) {
473  it1.add_to_end(bbox2);
474  } else if (bbox1 != bbox2) {
475  it1.add_before_stay_put(bbox2);
476  }
477  }
478  Fit(vertical, true);
479  other->Delete(this);
480 }
Definition: rect.h:34
const TBOX & bounding_box() const
Definition: blobbox.h:230
int16_t bottom() const
Definition: rect.h:65
bool Fit(ICOORD vertical, bool force_parallel)
Definition: tabvector.cpp:782
bool tesseract::TabVector::Partnerless ( )
inline

Definition at line 240 of file tabvector.h.

240  {
241  return partners_.empty();
242  }
TabVector_CLIST* tesseract::TabVector::partners ( )
inline

Definition at line 170 of file tabvector.h.

170  {
171  return &partners_;
172  }
void tesseract::TabVector::Print ( const char *  prefix)

Definition at line 519 of file tabvector.cpp.

519  {
520  tprintf(
521  "%s %s (%d,%d)->(%d,%d) w=%d s=%d, sort key=%d, boxes=%d,"
522  " partners=%d\n",
523  prefix, kAlignmentNames[alignment_], startpt_.x(), startpt_.y(),
524  endpt_.x(), endpt_.y(), mean_width_, percent_score_, sort_key_,
525  boxes_.length(), partners_.length());
526 }
int16_t y() const
access_function
Definition: points.h:56
int16_t x() const
access function
Definition: points.h:52
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:36
void tesseract::TabVector::ReflectInYAxis ( )
inline

Definition at line 265 of file tabvector.h.

265  {
266  startpt_.set_x(-startpt_.x());
267  endpt_.set_x(-endpt_.x());
268  sort_key_ = -sort_key_;
269  if (alignment_ == TA_LEFT_ALIGNED)
270  alignment_ = TA_RIGHT_ALIGNED;
271  else if (alignment_ == TA_RIGHT_ALIGNED)
272  alignment_ = TA_LEFT_ALIGNED;
273  if (alignment_ == TA_LEFT_RAGGED)
274  alignment_ = TA_RIGHT_RAGGED;
275  else if (alignment_ == TA_RIGHT_RAGGED)
276  alignment_ = TA_LEFT_RAGGED;
277  }
void set_x(int16_t xin)
rewrite function
Definition: points.h:61
int16_t x() const
access function
Definition: points.h:52
void tesseract::TabVector::Rotate ( const FCOORD rotation)

Definition at line 275 of file tabvector.cpp.

275  {
276  startpt_.rotate(rotation);
277  endpt_.rotate(rotation);
278  int dx = endpt_.x() - startpt_.x();
279  int dy = endpt_.y() - startpt_.y();
280  if ((dy < 0 && abs(dy) > abs(dx)) || (dx < 0 && abs(dx) > abs(dy))) {
281  // Need to flip start/end.
282  ICOORD tmp = startpt_;
283  startpt_ = endpt_;
284  endpt_ = tmp;
285  }
286 }
void rotate(const FCOORD &vec)
Definition: points.h:536
integer coordinate
Definition: points.h:31
int16_t y() const
access_function
Definition: points.h:56
int16_t x() const
access function
Definition: points.h:52
void tesseract::TabVector::set_bottom_constraints ( TabConstraint_LIST *  constraints)
inline

Definition at line 167 of file tabvector.h.

167  {
168  bottom_constraints_ = constraints;
169  }
void tesseract::TabVector::set_endpt ( const ICOORD end)
inline

Definition at line 176 of file tabvector.h.

176  {
177  endpt_ = end;
178  }
void tesseract::TabVector::set_intersects_other_lines ( bool  value)
inline

Definition at line 182 of file tabvector.h.

182  {
183  intersects_other_lines_ = value;
184  }
void tesseract::TabVector::set_startpt ( const ICOORD start)
inline

Definition at line 173 of file tabvector.h.

173  {
174  startpt_ = start;
175  }
void tesseract::TabVector::set_top_constraints ( TabConstraint_LIST *  constraints)
inline

Definition at line 164 of file tabvector.h.

164  {
165  top_constraints_ = constraints;
166  }
void tesseract::TabVector::SetupConstraints ( )

Definition at line 290 of file tabvector.cpp.

290  {
291  TabConstraint::CreateConstraint(this, false);
293 }
static void CreateConstraint(TabVector *vector, bool is_top)
Definition: tabvector.cpp:63
void tesseract::TabVector::SetupPartnerConstraints ( )

Definition at line 296 of file tabvector.cpp.

296  {
297  // With the first and last partner, we want a common bottom and top,
298  // respectively, and for each change of partner, we want a common
299  // top of first with bottom of next.
300  TabVector_C_IT it(&partners_);
301  TabVector* prev_partner = nullptr;
302  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
303  TabVector* partner = it.data();
304  if (partner->top_constraints_ == nullptr ||
305  partner->bottom_constraints_ == nullptr) {
306  partner->Print("Impossible: has no constraints");
307  Print("This vector has it as a partner");
308  continue;
309  }
310  if (prev_partner == nullptr) {
311  // This is the first partner, so common bottom.
312  if (TabConstraint::CompatibleConstraints(bottom_constraints_,
313  partner->bottom_constraints_))
314  TabConstraint::MergeConstraints(bottom_constraints_,
315  partner->bottom_constraints_);
316  } else {
317  // We need prev top to be common with partner bottom.
318  if (TabConstraint::CompatibleConstraints(prev_partner->top_constraints_,
319  partner->bottom_constraints_))
320  TabConstraint::MergeConstraints(prev_partner->top_constraints_,
321  partner->bottom_constraints_);
322  }
323  prev_partner = partner;
324  if (it.at_last()) {
325  // This is the last partner, so common top.
326  if (TabConstraint::CompatibleConstraints(top_constraints_,
327  partner->top_constraints_))
328  TabConstraint::MergeConstraints(top_constraints_,
329  partner->top_constraints_);
330  }
331  }
332 }
static void MergeConstraints(TabConstraint_LIST *list1, TabConstraint_LIST *list2)
Definition: tabvector.cpp:92
void Print(const char *prefix)
Definition: tabvector.cpp:519
static bool CompatibleConstraints(TabConstraint_LIST *list1, TabConstraint_LIST *list2)
Definition: tabvector.cpp:75
void tesseract::TabVector::SetupPartnerConstraints ( TabVector partner)

Definition at line 335 of file tabvector.cpp.

335  {
336  if (TabConstraint::CompatibleConstraints(bottom_constraints_,
337  partner->bottom_constraints_))
338  TabConstraint::MergeConstraints(bottom_constraints_,
339  partner->bottom_constraints_);
340  if (TabConstraint::CompatibleConstraints(top_constraints_,
341  partner->top_constraints_))
342  TabConstraint::MergeConstraints(top_constraints_,
343  partner->top_constraints_);
344 }
static void MergeConstraints(TabConstraint_LIST *list1, TabConstraint_LIST *list2)
Definition: tabvector.cpp:92
static bool CompatibleConstraints(TabConstraint_LIST *list1, TabConstraint_LIST *list2)
Definition: tabvector.cpp:75
void tesseract::TabVector::SetYEnd ( int  end_y)

Definition at line 269 of file tabvector.cpp.

269  {
270  endpt_.set_x(XAtY(end_y));
271  endpt_.set_y(end_y);
272 }
void set_x(int16_t xin)
rewrite function
Definition: points.h:61
void set_y(int16_t yin)
rewrite function
Definition: points.h:65
int XAtY(int y) const
Definition: tabvector.h:189
void tesseract::TabVector::SetYStart ( int  start_y)

Definition at line 264 of file tabvector.cpp.

264  {
265  startpt_.set_x(XAtY(start_y));
266  startpt_.set_y(start_y);
267 }
void set_x(int16_t xin)
rewrite function
Definition: points.h:61
void set_y(int16_t yin)
rewrite function
Definition: points.h:65
int XAtY(int y) const
Definition: tabvector.h:189
TabVector * tesseract::TabVector::ShallowCopy ( ) const

Definition at line 227 of file tabvector.cpp.

227  {
228  auto* copy = new TabVector();
229  copy->startpt_ = startpt_;
230  copy->endpt_ = endpt_;
231  copy->alignment_ = alignment_;
232  copy->extended_ymax_ = extended_ymax_;
233  copy->extended_ymin_ = extended_ymin_;
234  copy->intersects_other_lines_ = intersects_other_lines_;
235  return copy;
236 }
bool tesseract::TabVector::SimilarTo ( const ICOORD vertical,
const TabVector other,
BlobGrid grid 
) const

Definition at line 388 of file tabvector.cpp.

389  {
390  if ((IsRightTab() && other.IsRightTab()) ||
391  (IsLeftTab() && other.IsLeftTab())) {
392  // If they don't overlap, at least in extensions, then there is no chance.
393  if (ExtendedOverlap(other.extended_ymax_, other.extended_ymin_) < 0)
394  return false;
395  // A fast approximation to the scale factor of the sort_key_.
396  int v_scale = abs(vertical.y());
397  if (v_scale == 0)
398  v_scale = 1;
399  // If they are close enough, then OK.
400  if (sort_key_ + kSimilarVectorDist * v_scale >= other.sort_key_ &&
401  sort_key_ - kSimilarVectorDist * v_scale <= other.sort_key_)
402  return true;
403  // Ragged tabs get a bigger threshold.
404  if (!IsRagged() || !other.IsRagged() ||
405  sort_key_ + kSimilarRaggedDist * v_scale < other.sort_key_ ||
406  sort_key_ - kSimilarRaggedDist * v_scale > other.sort_key_)
407  return false;
408  if (grid == nullptr) {
409  // There is nothing else to test!
410  return true;
411  }
412  // If there is nothing in the rectangle between the vector that is going to
413  // move, and the place it is moving to, then they can be merged.
414  // Setup a vertical search for any blob.
415  const TabVector* mover = (IsRightTab() &&
416  sort_key_ < other.sort_key_) ? this : &other;
417  int top_y = mover->endpt_.y();
418  int bottom_y = mover->startpt_.y();
419  int left = std::min(mover->XAtY(top_y), mover->XAtY(bottom_y));
420  int right = std::max(mover->XAtY(top_y), mover->XAtY(bottom_y));
421  int shift = abs(sort_key_ - other.sort_key_) / v_scale;
422  if (IsRightTab()) {
423  right += shift;
424  } else {
425  left -= shift;
426  }
427 
428  GridSearch<BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT> vsearch(grid);
429  vsearch.StartVerticalSearch(left, right, top_y);
430  BLOBNBOX* blob;
431  while ((blob = vsearch.NextVerticalSearch(true)) != nullptr) {
432  const TBOX& box = blob->bounding_box();
433  if (box.top() > bottom_y)
434  return true; // Nothing found.
435  if (box.bottom() < top_y)
436  continue; // Doesn't overlap.
437  int left_at_box = XAtY(box.bottom());
438  int right_at_box = left_at_box;
439  if (IsRightTab())
440  right_at_box += shift;
441  else
442  left_at_box -= shift;
443  if (std::min(right_at_box, static_cast<int>(box.right())) > std::max(left_at_box, static_cast<int>(box.left())))
444  return false;
445  }
446  return true; // Nothing found.
447  }
448  return false;
449 }
int16_t top() const
Definition: rect.h:58
Definition: rect.h:34
const int kSimilarVectorDist
Definition: tabvector.cpp:39
bool IsLeftTab() const
Definition: tabvector.h:213
const TBOX & bounding_box() const
Definition: blobbox.h:230
const int kSimilarRaggedDist
Definition: tabvector.cpp:42
int16_t y() const
access_function
Definition: points.h:56
int ExtendedOverlap(int top_y, int bottom_y) const
Definition: tabvector.h:208
int16_t right() const
Definition: rect.h:79
int16_t bottom() const
Definition: rect.h:65
int XAtY(int y) const
Definition: tabvector.h:189
int16_t left() const
Definition: rect.h:72
bool IsRagged() const
Definition: tabvector.h:229
bool IsRightTab() const
Definition: tabvector.h:217
int tesseract::TabVector::sort_key ( ) const
inline

Definition at line 158 of file tabvector.h.

158  {
159  return sort_key_;
160  }
static int tesseract::TabVector::SortKey ( const ICOORD vertical,
int  x,
int  y 
)
inlinestatic

Definition at line 280 of file tabvector.h.

280  {
281  ICOORD pt(x, y);
282  return pt * vertical;
283  }
integer coordinate
Definition: points.h:31
static int tesseract::TabVector::SortVectorsByKey ( const void *  v1,
const void *  v2 
)
inlinestatic

Definition at line 294 of file tabvector.h.

294  {
295  const TabVector* tv1 = *static_cast<const TabVector* const*>(v1);
296  const TabVector* tv2 = *static_cast<const TabVector* const*>(v2);
297  return tv1->sort_key_ - tv2->sort_key_;
298  }
const ICOORD& tesseract::TabVector::startpt ( ) const
inline

Definition at line 146 of file tabvector.h.

146  {
147  return startpt_;
148  }
TabVector * tesseract::TabVector::VerticalTextlinePartner ( )

Definition at line 878 of file tabvector.cpp.

878  {
879  if (!partners_.singleton())
880  return nullptr;
881  TabVector_C_IT partner_it(&partners_);
882  TabVector* partner = partner_it.data();
883  BLOBNBOX_C_IT box_it1(&boxes_);
884  BLOBNBOX_C_IT box_it2(&partner->boxes_);
885  // Count how many boxes are also in the other list.
886  // At the same time, gather the mean width and median vertical gap.
887  if (textord_debug_tabfind > 1) {
888  Print("Testing for vertical text");
889  partner->Print(" partner");
890  }
891  int num_matched = 0;
892  int num_unmatched = 0;
893  int total_widths = 0;
894  int width = startpt().x() - partner->startpt().x();
895  if (width < 0)
896  width = -width;
897  STATS gaps(0, width * 2);
898  BLOBNBOX* prev_bbox = nullptr;
899  box_it2.mark_cycle_pt();
900  for (box_it1.mark_cycle_pt(); !box_it1.cycled_list(); box_it1.forward()) {
901  BLOBNBOX* bbox = box_it1.data();
902  TBOX box = bbox->bounding_box();
903  if (prev_bbox != nullptr) {
904  gaps.add(box.bottom() - prev_bbox->bounding_box().top(), 1);
905  }
906  while (!box_it2.cycled_list() && box_it2.data() != bbox &&
907  box_it2.data()->bounding_box().bottom() < box.bottom()) {
908  box_it2.forward();
909  }
910  if (!box_it2.cycled_list() && box_it2.data() == bbox &&
911  bbox->region_type() >= BRT_UNKNOWN &&
912  (prev_bbox == nullptr || prev_bbox->region_type() >= BRT_UNKNOWN))
913  ++num_matched;
914  else
915  ++num_unmatched;
916  total_widths += box.width();
917  prev_bbox = bbox;
918  }
919  if (num_unmatched + num_matched == 0) return nullptr;
920  double avg_width = total_widths * 1.0 / (num_unmatched + num_matched);
921  double max_gap = textord_tabvector_vertical_gap_fraction * avg_width;
922  int min_box_match = static_cast<int>((num_matched + num_unmatched) *
924  bool is_vertical = (gaps.get_total() > 0 &&
925  num_matched >= min_box_match &&
926  gaps.median() <= max_gap);
927  if (textord_debug_tabfind > 1) {
928  tprintf("gaps=%d, matched=%d, unmatched=%d, min_match=%d "
929  "median gap=%.2f, width=%.2f max_gap=%.2f Vertical=%s\n",
930  gaps.get_total(), num_matched, num_unmatched, min_box_match,
931  gaps.median(), avg_width, max_gap, is_vertical?"Yes":"No");
932  }
933  return (is_vertical) ? partner : nullptr;
934 }
int16_t top() const
Definition: rect.h:58
Definition: rect.h:34
void Print(const char *prefix)
Definition: tabvector.cpp:519
const TBOX & bounding_box() const
Definition: blobbox.h:230
double textord_tabvector_vertical_box_ratio
Definition: tabvector.cpp:58
double textord_tabvector_vertical_gap_fraction
Definition: tabvector.cpp:55
const ICOORD & startpt() const
Definition: tabvector.h:146
int16_t x() const
access function
Definition: points.h:52
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:36
int textord_debug_tabfind
Definition: alignedblob.cpp:27
int16_t width() const
Definition: rect.h:115
int16_t bottom() const
Definition: rect.h:65
BlobRegionType region_type() const
Definition: blobbox.h:283
Definition: statistc.h:31
int tesseract::TabVector::VOverlap ( const TabVector other) const
inline

Definition at line 199 of file tabvector.h.

199  {
200  return std::min(other.endpt_.y(), endpt_.y()) -
201  std::max(other.startpt_.y(), startpt_.y());
202  }
int16_t y() const
access_function
Definition: points.h:56
int tesseract::TabVector::VOverlap ( int  top_y,
int  bottom_y 
) const
inline

Definition at line 204 of file tabvector.h.

204  {
205  return std::min(top_y, static_cast<int>(endpt_.y())) - std::max(bottom_y, static_cast<int>(startpt_.y()));
206  }
int16_t y() const
access_function
Definition: points.h:56
int tesseract::TabVector::XAtY ( int  y) const
inline

Definition at line 189 of file tabvector.h.

189  {
190  int height = endpt_.y() - startpt_.y();
191  if (height != 0)
192  return (y - startpt_.y()) * (endpt_.x() - startpt_.x()) / height +
193  startpt_.x();
194  else
195  return startpt_.x();
196  }
int16_t y() const
access_function
Definition: points.h:56
int16_t x() const
access function
Definition: points.h:52
static int tesseract::TabVector::XAtY ( const ICOORD vertical,
int  sort_key,
int  y 
)
inlinestatic

Definition at line 286 of file tabvector.h.

286  {
287  if (vertical.y() != 0)
288  return (vertical.x() * y + sort_key) / vertical.y();
289  else
290  return sort_key;
291  }
int16_t y() const
access_function
Definition: points.h:56
int16_t x() const
access function
Definition: points.h:52
int sort_key() const
Definition: tabvector.h:158
void tesseract::TabVector::XYFlip ( )
inline

Definition at line 255 of file tabvector.h.

255  {
256  int x = startpt_.y();
257  startpt_.set_y(startpt_.x());
258  startpt_.set_x(x);
259  x = endpt_.y();
260  endpt_.set_y(endpt_.x());
261  endpt_.set_x(x);
262  }
void set_x(int16_t xin)
rewrite function
Definition: points.h:61
int16_t y() const
access_function
Definition: points.h:56
void set_y(int16_t yin)
rewrite function
Definition: points.h:65
int16_t x() const
access function
Definition: points.h:52

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