tesseract
5.0.0-alpha-619-ge9db
|
#include <colfind.h>
|
| ColumnFinder (int gridsize, const ICOORD &bleft, const ICOORD &tright, int resolution, bool cjk_script, double aligned_gap_fraction, TabVector_LIST *vlines, TabVector_LIST *hlines, int vertical_x, int vertical_y) |
|
| ~ColumnFinder () override |
|
const DENORM * | denorm () const |
|
const TextlineProjection * | projection () const |
|
void | set_cjk_script (bool is_cjk) |
|
void | SetupAndFilterNoise (PageSegMode pageseg_mode, Pix *photo_mask_pix, TO_BLOCK *input_block) |
|
bool | IsVerticallyAlignedText (double find_vertical_text_ratio, TO_BLOCK *block, BLOBNBOX_CLIST *osd_blobs) |
|
void | CorrectOrientation (TO_BLOCK *block, bool vertical_text_lines, int recognition_rotation) |
|
int | FindBlocks (PageSegMode pageseg_mode, Pix *scaled_color, int scaled_factor, TO_BLOCK *block, Pix *photo_mask_pix, Pix *thresholds_pix, Pix *grey_pix, DebugPixa *pixa_debug, BLOCK_LIST *blocks, BLOBNBOX_LIST *diacritic_blobs, TO_BLOCK_LIST *to_blocks) |
|
void | GetDeskewVectors (FCOORD *deskew, FCOORD *reskew) |
|
void | SetEquationDetect (EquationDetectBase *detect) |
|
| 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, Pix *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 bool | DifferentSizes (int size1, int size2) |
|
static bool | VeryDifferentSizes (int size1, int size2) |
|
static bool | WithinTestRegion (int detail_level, int x, int y) |
|
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 void | RotateBlobList (const FCOORD &rotation, BLOBNBOX_LIST *blobs) |
|
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_ |
|
Definition at line 50 of file colfind.h.
◆ ColumnFinder()
tesseract::ColumnFinder::ColumnFinder |
( |
int |
gridsize, |
|
|
const ICOORD & |
bleft, |
|
|
const ICOORD & |
tright, |
|
|
int |
resolution, |
|
|
bool |
cjk_script, |
|
|
double |
aligned_gap_fraction, |
|
|
TabVector_LIST * |
vlines, |
|
|
TabVector_LIST * |
hlines, |
|
|
int |
vertical_x, |
|
|
int |
vertical_y |
|
) |
| |
Definition at line 74 of file colfind.cpp.
82 cjk_script_(cjk_script),
85 tabfind_aligned_gap_fraction_(aligned_gap_fraction),
87 reskew_(1.0f, 0.0f), rotation_(1.0f, 0.0f), rerotate_(1.0f, 0.0f),
88 text_rotation_(0.0f, 0.0f),
89 best_columns_(
nullptr), stroke_width_(
nullptr),
91 projection_(resolution),
92 denorm_(
nullptr), input_blobs_win_(
nullptr), equation_detect_(
nullptr) {
93 TabVector_IT h_it(&horizontal_lines_);
94 h_it.add_list_after(hlines);
◆ ~ColumnFinder()
tesseract::ColumnFinder::~ColumnFinder |
( |
| ) |
|
|
override |
Definition at line 97 of file colfind.cpp.
99 delete [] best_columns_;
100 delete stroke_width_;
101 delete input_blobs_win_;
102 pixDestroy(&nontext_map_);
103 while (denorm_ !=
nullptr) {
104 DENORM* dead_denorm = denorm_;
105 denorm_ = const_cast<DENORM*>(denorm_->
predecessor());
111 ColPartition_IT part_it(&noise_parts_);
112 for (part_it.mark_cycle_pt(); !part_it.cycled_list(); part_it.forward()) {
113 ColPartition* part = part_it.data();
119 part_it.set_to_list(&good_parts_);
120 for (part_it.mark_cycle_pt(); !part_it.cycled_list(); part_it.forward()) {
121 ColPartition* part = part_it.data();
128 BLOBNBOX_IT bb_it(&image_bblobs_);
129 for (bb_it.mark_cycle_pt(); !bb_it.cycled_list(); bb_it.forward()) {
131 delete bblob->
cblob();
◆ CorrectOrientation()
void tesseract::ColumnFinder::CorrectOrientation |
( |
TO_BLOCK * |
block, |
|
|
bool |
vertical_text_lines, |
|
|
int |
recognition_rotation |
|
) |
| |
Definition at line 197 of file colfind.cpp.
200 const FCOORD anticlockwise90(0.0f, 1.0f);
201 const FCOORD clockwise90(0.0f, -1.0f);
202 const FCOORD rotation180(-1.0f, 0.0f);
203 const FCOORD norotation(1.0f, 0.0f);
205 text_rotation_ = norotation;
208 rotation_ = norotation;
209 if (recognition_rotation == 1) {
210 rotation_ = anticlockwise90;
211 }
else if (recognition_rotation == 2) {
212 rotation_ = rotation180;
213 }
else if (recognition_rotation == 3) {
214 rotation_ = clockwise90;
220 if (recognition_rotation & 1) {
221 vertical_text_lines = !vertical_text_lines;
227 if (vertical_text_lines) {
228 rotation_.
rotate(anticlockwise90);
229 text_rotation_.
rotate(clockwise90);
232 rerotate_ =
FCOORD(rotation_.
x(), -rotation_.
y());
233 if (rotation_.
x() != 1.0f || rotation_.
y() != 0.0f) {
249 tprintf(
"Vertical=%d, orientation=%d, final rotation=(%f, %f)+(%f,%f)\n",
250 vertical_text_lines, recognition_rotation,
251 rotation_.
x(), rotation_.
y(),
252 text_rotation_.
x(), text_rotation_.
y());
258 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f);
◆ denorm()
const DENORM* tesseract::ColumnFinder::denorm |
( |
| ) |
const |
|
inline |
◆ FindBlocks()
int tesseract::ColumnFinder::FindBlocks |
( |
PageSegMode |
pageseg_mode, |
|
|
Pix * |
scaled_color, |
|
|
int |
scaled_factor, |
|
|
TO_BLOCK * |
block, |
|
|
Pix * |
photo_mask_pix, |
|
|
Pix * |
thresholds_pix, |
|
|
Pix * |
grey_pix, |
|
|
DebugPixa * |
pixa_debug, |
|
|
BLOCK_LIST * |
blocks, |
|
|
BLOBNBOX_LIST * |
diacritic_blobs, |
|
|
TO_BLOCK_LIST * |
to_blocks |
|
) |
| |
Definition at line 285 of file colfind.cpp.
291 pixOr(photo_mask_pix, photo_mask_pix, nontext_map_);
298 pageseg_mode, rerotate_, input_block, nontext_map_, denorm_, cjk_script_,
299 &projection_, diacritic_blobs, &part_grid_, &big_parts_);
302 input_block,
this, pixa_debug, &part_grid_,
307 input_block,
this, pixa_debug, &part_grid_,
314 ColPartition_IT p_it(&big_parts_);
315 for (p_it.mark_cycle_pt(); !p_it.cycled_list(); p_it.forward())
316 p_it.data()->DisownBoxesNoAssert();
318 delete stroke_width_;
319 stroke_width_ =
nullptr;
324 input_block->ComputeEdgeOffsets(thresholds_pix, grey_pix);
340 bool input_is_rtl = input_block->block->right_to_left();
345 ReflectForRtl(input_block, &image_bblobs_);
358 min_gutter_width_, tabfind_aligned_gap_fraction_,
359 &part_grid_, &deskew_, &reskew_);
361 auto* new_denorm =
new DENORM;
363 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f);
364 denorm_ = new_denorm;
370 if (!MakeColumns(
false)) {
379 #ifndef GRAPHICS_DISABLED
380 if (textord_tabfind_show_reject_blobs) {
382 input_block->plot_graded_blobs(rej_win);
384 #endif // GRAPHICS_DISABLED
390 GridSplitPartitions();
394 GridMergePartitions();
397 InsertRemainingNoise(input_block);
399 GridInsertHLinePartitions();
400 GridInsertVLinePartitions();
405 if (textord_tabfind_show_initial_partitions) {
412 if (equation_detect_) {
415 if (textord_tabfind_find_tables) {
416 TableFinder table_finder;
419 table_finder.set_left_to_right_language(
420 !input_block->block->right_to_left());
423 table_finder.InsertCleanPartitions(&part_grid_, input_block);
425 table_finder.LocateTables(&part_grid_, best_columns_,
WidthCB(), reskew_);
427 GridRemoveUnderlinePartitions();
437 #ifndef GRAPHICS_DISABLED
438 if (textord_tabfind_show_partitions) {
440 if (window !=
nullptr) {
444 if (window !=
nullptr && textord_tabfind_show_partitions > 1) {
449 #endif // GRAPHICS_DISABLED
455 ReleaseBlobsAndCleanupUnused(input_block);
463 TransformToBlocks(blocks, to_blocks);
465 tprintf(
"Found %d blocks, %d to_blocks\n",
466 blocks->length(), to_blocks->length());
469 DisplayBlocks(blocks);
470 RotateAndReskewBlocks(input_is_rtl, to_blocks);
472 #ifndef GRAPHICS_DISABLED
473 if (blocks_win_ !=
nullptr) {
474 bool waiting =
false;
478 if (event->type ==
SVET_INPUT && event->parameter !=
nullptr) {
479 if (*event->parameter ==
'd')
484 blocks_win_ =
nullptr;
491 #endif // GRAPHICS_DISABLED
◆ GetDeskewVectors()
void tesseract::ColumnFinder::GetDeskewVectors |
( |
FCOORD * |
deskew, |
|
|
FCOORD * |
reskew |
|
) |
| |
◆ IsVerticallyAlignedText()
bool tesseract::ColumnFinder::IsVerticallyAlignedText |
( |
double |
find_vertical_text_ratio, |
|
|
TO_BLOCK * |
block, |
|
|
BLOBNBOX_CLIST * |
osd_blobs |
|
) |
| |
◆ projection()
◆ set_cjk_script()
void tesseract::ColumnFinder::set_cjk_script |
( |
bool |
is_cjk | ) |
|
|
inline |
◆ SetEquationDetect()
Definition at line 502 of file colfind.cpp.
503 equation_detect_ = detect;
◆ SetupAndFilterNoise()
void tesseract::ColumnFinder::SetupAndFilterNoise |
( |
PageSegMode |
pageseg_mode, |
|
|
Pix * |
photo_mask_pix, |
|
|
TO_BLOCK * |
input_block |
|
) |
| |
Definition at line 142 of file colfind.cpp.
146 delete stroke_width_;
150 #ifndef GRAPHICS_DISABLED
151 if (textord_tabfind_show_blocks) {
152 input_blobs_win_ =
MakeWindow(0, 0,
"Filtered Input Blobs");
155 #endif // GRAPHICS_DISABLED
157 pixDestroy(&nontext_map_);
163 photo_mask_pix, input_block);
167 stroke_width_->
Clear();
The documentation for this class was generated from the following files:
void delete_data_pointers()
BLOBNBOX_LIST small_blobs
void plot_graded_blobs(ScrollView *to_win)
void GridFindMargins(ColPartitionSet **best_columns)
void AssertNoDuplicates()
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 DeleteUnknownParts(TO_BLOCK *block)
ScrollView * MakeWindow(int x, int y, const char *window_name)
BLOBNBOX_LIST noise_blobs
bool PSM_COL_FIND_ENABLED(int pageseg_mode)
const double kMinGutterWidthGrid
void GradeBlobsIntoPartitions(PageSegMode pageseg_mode, const FCOORD &rerotation, TO_BLOCK *block, Pix *nontext_pix, const DENORM *denorm, bool cjk_script, TextlineProjection *projection, BLOBNBOX_LIST *diacritic_blobs, ColPartitionGrid *part_grid, ColPartition_LIST *big_parts)
void FindFigureCaptions()
int16_t x() const
access function
const DENORM * predecessor() const
void set_y(float yin)
rewrite function
void InsertBlobsToGrid(bool h_spread, bool v_spread, BLOBNBOX_LIST *blobs, BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT > *grid)
const ICOORD & tright() const
ScrollView * FindInitialTabVectors(BLOBNBOX_LIST *image_blobs, int min_gutter_width, double tabfind_aligned_gap_fraction, TO_BLOCK *block)
bool PSM_SPARSE(int pageseg_mode)
void ReSetAndReFilterBlobs()
void RefinePartitionPartners(bool get_desperate)
void SetupNormalization(const BLOCK *block, const FCOORD *rotation, const DENORM *predecessor, float x_origin, float y_origin, float x_scale, float y_scale, float final_xshift, float final_yshift)
int resolution_
Of source image in pixels per inch.
BLOBNBOX_LIST large_blobs
bool textord_debug_printable
void FindTextlineDirectionAndFixBrokenCJK(PageSegMode pageseg_mode, bool cjk_merge, TO_BLOCK *input_block)
void DontFindTabVectors(BLOBNBOX_LIST *image_blobs, TO_BLOCK *block, FCOORD *deskew, FCOORD *reskew)
static void FindImagePartitions(Pix *image_pix, const FCOORD &rotation, const FCOORD &rerotation, TO_BLOCK *block, TabFind *tab_grid, DebugPixa *pixa_debug, ColPartitionGrid *part_grid, ColPartition_LIST *big_parts)
void CorrectForRotation(const FCOORD &rerotation, ColPartitionGrid *part_grid)
void rotate(const FCOORD vec)
bool TestVerticalTextDirection(double find_vertical_text_ratio, TO_BLOCK *block, BLOBNBOX_CLIST *osd_blobs)
TabFind(int gridsize, const ICOORD &bleft, const ICOORD &tright, TabVector_LIST *vlines, int vertical_x, int vertical_y, int resolution)
void SetBlockRuleEdges(TO_BLOCK *block)
SVEvent * AwaitEvent(SVEventType type)
static void TransferImagePartsToImageMask(const FCOORD &rerotation, ColPartitionGrid *part_grid, Pix *image_mask)
ScrollView * DisplayTabVectors(ScrollView *tab_win)
void DisplayBoxes(ScrollView *window)
void FindPartitionPartners()
void Init(int gridsize, const ICOORD &bleft, const ICOORD &tright)
void ResetForVerticalText(const FCOORD &rotate, const FCOORD &rerotate, TabVector_LIST *horizontal_lines, int *min_gutter_width)
void FindLeaderPartitions(TO_BLOCK *block, ColPartitionGrid *part_grid)
void ReTypeBlobs(BLOBNBOX_LIST *im_blobs)
void SetNeighboursOnMediumBlobs(TO_BLOCK *block)
void SetTabStops(TabFind *tabgrid)
DLLSYM void tprintf(const char *format,...)
void RemoveLineResidue(ColPartition_LIST *big_part_list)
void TidyBlobs(TO_BLOCK *block)
int textord_debug_tabfind
const ICOORD & bleft() const
void ExtractPartitionsAsBlocks(BLOCK_LIST *blocks, TO_BLOCK_LIST *to_blocks)
virtual int FindEquationParts(ColPartitionGrid *part_grid, ColPartitionSet **best_columns)=0
static void RotateBlobList(const FCOORD &rotation, BLOBNBOX_LIST *blobs)