19#ifndef TESSERACT_TEXTORD_TABFIND_H_
20#define TESSERACT_TEXTORD_TABFIND_H_
55 int vertical_x,
int vertical_y,
int resolution);
66 void InsertBlobsToGrid(
bool h_spread,
bool v_spread, BLOBNBOX_LIST *blobs,
76 bool InsertBlob(
bool h_spread,
bool v_spread,
BLOBNBOX *blob,
79 void SetBlockRuleEdges(
TO_BLOCK *block);
82 void SetBlobRuleEdges(BLOBNBOX_LIST *blobs);
91 int GutterWidth(
int bottom_y,
int top_y,
const TabVector &v,
bool ignore_unmergeables,
92 int max_gutter_width,
int *required_shift);
96 void GutterWidthAndNeighbourGap(
int tab_x,
int mean_height,
int max_gutter,
bool left,
97 BLOBNBOX *bbox,
int *gutter_width,
int *neighbour_gap);
105 int RightEdgeForBox(
const TBOX &box,
bool crossing,
bool extended);
109 int LeftEdgeForBox(
const TBOX &box,
bool crossing,
bool extended);
127 TabVector *RightTabForBox(
const TBOX &box,
bool crossing,
bool extended);
131 TabVector *LeftTabForBox(
const TBOX &box,
bool crossing,
bool extended);
137 bool CommonWidth(
int width);
142 static bool DifferentSizes(
int size1,
int size2);
147 static bool VeryDifferentSizes(
int size1,
int size2);
160 return image_origin_;
171 return &dead_vectors_;
181 bool FindTabVectors(TabVector_LIST *hlines, BLOBNBOX_LIST *image_blobs,
TO_BLOCK *block,
182 int min_gutter_width,
double tabfind_aligned_gap_fraction,
187 void DontFindTabVectors(BLOBNBOX_LIST *image_blobs,
TO_BLOCK *block,
FCOORD *deskew,
196 void SetupTabSearch(
int x,
int y,
int *min_key,
int *max_key);
210 ScrollView *FindInitialTabVectors(BLOBNBOX_LIST *image_blobs,
int min_gutter_width,
211 double tabfind_aligned_gap_fraction,
TO_BLOCK *block);
214 static void RotateBlobList(
const FCOORD &rotation, BLOBNBOX_LIST *blobs);
220 void ResetForVerticalText(
const FCOORD &rotate,
const FCOORD &rerotate,
221 TabVector_LIST *horizontal_lines,
int *min_gutter_width);
229 void ReflectInYAxis();
236 ScrollView *FindTabBoxes(
int min_gutter_width,
double tabfind_aligned_gap_fraction);
242 bool TestBoxForTabs(
BLOBNBOX *bbox,
int min_gutter_width,
double tabfind_aligned_gap_fraction);
246 bool ConfirmRaggedLeft(
BLOBNBOX *bbox,
int min_gutter);
249 bool ConfirmRaggedRight(
BLOBNBOX *bbox,
int min_gutter);
252 bool NothingYOverlapsInBox(
const TBOX &search_box,
const TBOX &target_box);
256 void FindAllTabVectors(
int min_gutter_width);
258 int FindTabVectors(
int search_size_multiple,
TabAlignment alignment,
int min_gutter_width,
259 TabVector_LIST *vectors,
int *vertical_x,
int *vertical_y);
268 BLOBNBOX *bbox,
int *vertical_x,
int *vertical_y);
272 void SetVerticalSkewAndParallelize(
int vertical_x,
int vertical_y);
296 void MakeColumnWidths(
int col_widths_size,
STATS *col_widths);
299 void MarkVerticalText();
304 int FindMedianGutterWidth(TabVector_LIST *tab_vectors);
311 BLOBNBOX *AdjacentBlob(
const BLOBNBOX *bbox,
bool look_left,
bool ignore_images,
312 double min_overlap_fraction,
int gap_limit,
int top_y,
int bottom_y);
332 bool Deskew(TabVector_LIST *hlines, BLOBNBOX_LIST *image_blobs,
TO_BLOCK *block,
FCOORD *deskew,
336 void ComputeDeskewVectors(
FCOORD *deskew,
FCOORD *reskew);
342 void ApplyTabConstraints();
349 TabVector_LIST vectors_;
351 TabVector_LIST dead_vectors_;
353 ICOORDELT_LIST column_widths_;
357 std::vector<BLOBNBOX *> left_tab_boxes_;
358 std::vector<BLOBNBOX *> right_tab_boxes_;
const int kColumnWidthFactor
std::function< bool(int)> WidthCallback
TabVector_LIST * dead_vectors()
int resolution_
Of source image in pixels per inch.
const ICOORD & image_origin() const
TabVector_LIST * vectors()
ICOORD vertical_skew_
Estimate of true vertical in this image.