tesseract v5.3.3.20231005
|
#include <tabfind.h>
Public Member Functions | |
TabFind (int gridsize, const ICOORD &bleft, const ICOORD &tright, TabVector_LIST *vlines, int vertical_x, int vertical_y, int resolution) | |
~TabFind () override | |
void | InsertBlobsToGrid (bool h_spread, bool v_spread, BLOBNBOX_LIST *blobs, BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT > *grid) |
bool | InsertBlob (bool h_spread, bool v_spread, BLOBNBOX *blob, BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT > *grid) |
void | SetBlockRuleEdges (TO_BLOCK *block) |
void | SetBlobRuleEdges (BLOBNBOX_LIST *blobs) |
int | GutterWidth (int bottom_y, int top_y, const TabVector &v, bool ignore_unmergeables, int max_gutter_width, int *required_shift) |
void | GutterWidthAndNeighbourGap (int tab_x, int mean_height, int max_gutter, bool left, BLOBNBOX *bbox, int *gutter_width, int *neighbour_gap) |
int | RightEdgeForBox (const TBOX &box, bool crossing, bool extended) |
int | LeftEdgeForBox (const TBOX &box, bool crossing, bool extended) |
TabVector * | RightTabForBox (const TBOX &box, bool crossing, bool extended) |
TabVector * | LeftTabForBox (const TBOX &box, bool crossing, bool extended) |
bool | CommonWidth (int width) |
WidthCallback | WidthCB () |
const ICOORD & | image_origin () const |
![]() | |
AlignedBlob (int gridsize, const ICOORD &bleft, const ICOORD &tright) | |
~AlignedBlob () override | |
ScrollView * | DisplayTabs (const char *window_name, ScrollView *tab_win) |
TabVector * | FindVerticalAlignment (AlignedBlobParams align_params, BLOBNBOX *bbox, int *vertical_x, int *vertical_y) |
![]() | |
BlobGrid (int gridsize, const ICOORD &bleft, const ICOORD &tright) | |
~BlobGrid () override | |
void | InsertBlobList (BLOBNBOX_LIST *blobs) |
![]() | |
BBGrid () | |
BBGrid (int gridsize, const ICOORD &bleft, const ICOORD &tright) | |
~BBGrid () override | |
void | Init (int gridsize, const ICOORD &bleft, const ICOORD &tright) |
void | Clear () |
void | ClearGridData (void(*free_method)(BLOBNBOX *)) |
void | InsertBBox (bool h_spread, bool v_spread, BLOBNBOX *bbox) |
void | InsertPixPtBBox (int left, int bottom, Image pix, BLOBNBOX *bbox) |
void | RemoveBBox (BLOBNBOX *bbox) |
bool | RectangleEmpty (const TBOX &rect) |
IntGrid * | CountCellElements () |
ScrollView * | MakeWindow (int x, int y, const char *window_name) |
void | DisplayBoxes (ScrollView *window) |
void | AssertNoDuplicates () |
virtual void | HandleClick (int x, int y) |
![]() | |
GridBase ()=default | |
GridBase (int gridsize, const ICOORD &bleft, const ICOORD &tright) | |
virtual | ~GridBase () |
void | Init (int gridsize, const ICOORD &bleft, const ICOORD &tright) |
int | gridsize () const |
int | gridwidth () const |
int | gridheight () const |
const ICOORD & | bleft () const |
const ICOORD & | tright () const |
void | GridCoords (int x, int y, int *grid_x, int *grid_y) const |
void | ClipGridCoords (int *x, int *y) const |
Static Public Member Functions | |
static bool | DifferentSizes (int size1, int size2) |
static bool | VeryDifferentSizes (int size1, int size2) |
![]() | |
static bool | WithinTestRegion (int detail_level, int x, int y) |
Protected Member Functions | |
TabVector_LIST * | vectors () |
TabVector_LIST * | dead_vectors () |
bool | FindTabVectors (TabVector_LIST *hlines, BLOBNBOX_LIST *image_blobs, TO_BLOCK *block, int min_gutter_width, double tabfind_aligned_gap_fraction, ColPartitionGrid *part_grid, FCOORD *deskew, FCOORD *reskew) |
void | DontFindTabVectors (BLOBNBOX_LIST *image_blobs, TO_BLOCK *block, FCOORD *deskew, FCOORD *reskew) |
void | TidyBlobs (TO_BLOCK *block) |
void | SetupTabSearch (int x, int y, int *min_key, int *max_key) |
ScrollView * | DisplayTabVectors (ScrollView *tab_win) |
ScrollView * | FindInitialTabVectors (BLOBNBOX_LIST *image_blobs, int min_gutter_width, double tabfind_aligned_gap_fraction, TO_BLOCK *block) |
void | ResetForVerticalText (const FCOORD &rotate, const FCOORD &rerotate, TabVector_LIST *horizontal_lines, int *min_gutter_width) |
void | Reset () |
void | ReflectInYAxis () |
Static Protected Member Functions | |
static void | RotateBlobList (const FCOORD &rotation, BLOBNBOX_LIST *blobs) |
Protected Attributes | |
ICOORD | vertical_skew_ |
Estimate of true vertical in this image. More... | |
int | resolution_ |
Of source image in pixels per inch. More... | |
![]() | |
BLOBNBOX_CLIST * | grid_ |
![]() | |
int | gridsize_ |
int | gridwidth_ |
int | gridheight_ |
int | gridbuckets_ |
ICOORD | bleft_ |
ICOORD | tright_ |
The TabFind class contains code to find tab-stops and maintain the vectors_ list of tab vectors. Also provides an interface to find neighbouring blobs in the grid of BLOBNBOXes that is used by multiple subclasses. Searching is a complex operation because of the need to enforce rule/separator lines, and tabstop boundaries, (when available), so as the holder of the list of TabVectors this class provides the functions.
tesseract::TabFind::TabFind | ( | int | gridsize, |
const ICOORD & | bleft, | ||
const ICOORD & | tright, | ||
TabVector_LIST * | vlines, | ||
int | vertical_x, | ||
int | vertical_y, | ||
int | resolution | ||
) |
Definition at line 65 of file tabfind.cpp.
|
overridedefault |
bool tesseract::TabFind::CommonWidth | ( | int | width | ) |
Return true if the given width is close to one of the common widths in column_widths_.
Definition at line 393 of file tabfind.cpp.
|
inlineprotected |
|
static |
Return true if the sizes are more than a factor of 2 different.
Definition at line 407 of file tabfind.cpp.
|
protected |
Display the tab vectors found in this grid.
Definition at line 495 of file tabfind.cpp.
|
protected |
Definition at line 449 of file tabfind.cpp.
|
protected |
Definition at line 512 of file tabfind.cpp.
|
protected |
Top-level function to find TabVectors in an input page block. Returns false if the detected skew angle is impossible. Applies the detected skew angle to deskew the tabs, blobs and part_grid. tabfind_aligned_gap_fraction should be the value of parameter textord_tabfind_aligned_gap_fraction
Definition at line 422 of file tabfind.cpp.
int tesseract::TabFind::GutterWidth | ( | int | bottom_y, |
int | top_y, | ||
const TabVector & | v, | ||
bool | ignore_unmergeables, | ||
int | max_gutter_width, | ||
int * | required_shift | ||
) |
Definition at line 156 of file tabfind.cpp.
void tesseract::TabFind::GutterWidthAndNeighbourGap | ( | int | tab_x, |
int | mean_height, | ||
int | max_gutter, | ||
bool | left, | ||
BLOBNBOX * | bbox, | ||
int * | gutter_width, | ||
int * | neighbour_gap | ||
) |
Find the gutter width and distance to inner neighbour for the given blob.
Definition at line 206 of file tabfind.cpp.
|
inline |
bool tesseract::TabFind::InsertBlob | ( | bool | h_spread, |
bool | v_spread, | ||
BLOBNBOX * | blob, | ||
BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT > * | grid | ||
) |
Insert a single blob into the given grid (not necessarily this). If h_spread, then all cells covered horizontally by the box are used, otherwise, just the bottom-left. Similarly for v_spread. A side effect is that the left and right rule edges of the blob are set according to the tab vectors in this (not grid).
Definition at line 113 of file tabfind.cpp.
void tesseract::TabFind::InsertBlobsToGrid | ( | bool | h_spread, |
bool | v_spread, | ||
BLOBNBOX_LIST * | blobs, | ||
BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT > * | grid | ||
) |
Insert a list of blobs into the given grid (not necessarily this). See InsertBlob for the other arguments. It would seem to make more sense to swap this and grid, but this way around allows grid to not be derived from TabFind, eg a ColPartitionGrid, while the grid that provides the tab stops(this) has to be derived from TabFind.
Definition at line 89 of file tabfind.cpp.
int tesseract::TabFind::LeftEdgeForBox | ( | const TBOX & | box, |
bool | crossing, | ||
bool | extended | ||
) |
As RightEdgeForBox, but finds the left Edge instead.
Definition at line 284 of file tabfind.cpp.
As RightTabForBox, but finds the left TabVector instead.
Definition at line 347 of file tabfind.cpp.
|
protected |
Definition at line 1380 of file tabfind.cpp.
|
protected |
Definition at line 1368 of file tabfind.cpp.
|
protected |
Definition at line 1323 of file tabfind.cpp.
int tesseract::TabFind::RightEdgeForBox | ( | const TBOX & | box, |
bool | crossing, | ||
bool | extended | ||
) |
Return the x-coord that corresponds to the right edge for the given box. If there is a rule line to the right that vertically overlaps it, then return the x-coord of the rule line, otherwise return the right edge of the page. For details see RightTabForBox below.
Definition at line 279 of file tabfind.cpp.
Return the TabVector that corresponds to the right edge for the given box. If there is a TabVector to the right that vertically overlaps it, then return it, otherwise return nullptr. Note that Right and Left refer to the position of the TabVector, not its type, ie RightTabForBox returns the nearest TabVector to the right of the box, regardless of its type. If a TabVector crosses right through the box (as opposed to grazing one edge or missing entirely), then crossing false will ignore such a line. Crossing true will return the line for BOTH left and right edges. If extended is true, then TabVectors are considered to extend to their extended_start/end_y, otherwise, just the startpt_ and endpt_. These functions make use of an internal iterator to the vectors_ list for speed when used repeatedly on neighbouring boxes. The caveat is that the iterator must be updated whenever the list is modified.
Definition at line 302 of file tabfind.cpp.
|
staticprotected |
Definition at line 1278 of file tabfind.cpp.
void tesseract::TabFind::SetBlobRuleEdges | ( | BLOBNBOX_LIST * | blobs | ) |
Definition at line 137 of file tabfind.cpp.
void tesseract::TabFind::SetBlockRuleEdges | ( | TO_BLOCK * | block | ) |
Definition at line 128 of file tabfind.cpp.
|
protected |
Definition at line 486 of file tabfind.cpp.
|
protected |
Definition at line 462 of file tabfind.cpp.
|
inlineprotected |
|
static |
Return true if the sizes are more than a factor of 5 different.
Definition at line 413 of file tabfind.cpp.
|
inline |
|
protected |
|
protected |