tesseract
5.0.0-alpha-619-ge9db
|
#include <tablerecog.h>
Definition at line 72 of file tablerecog.h.
◆ StructuredTable()
tesseract::StructuredTable::StructuredTable |
( |
| ) |
|
◆ ~StructuredTable()
tesseract::StructuredTable::~StructuredTable |
( |
| ) |
|
|
default |
◆ AbsorbNearbyLines()
void tesseract::StructuredTable::AbsorbNearbyLines |
( |
| ) |
|
|
protected |
Definition at line 538 of file tablerecog.cpp.
540 gsearch.SetUniqueMode(
true);
545 ColPartition* line =
nullptr;
548 while ((line = gsearch.NextVerticalSearch(
false)) !=
nullptr) {
549 if (!line->IsHorizontalLine())
563 while ((line = gsearch.NextVerticalSearch(
true)) !=
nullptr) {
564 if (!line->IsHorizontalLine())
◆ bounding_box()
const TBOX & tesseract::StructuredTable::bounding_box |
( |
| ) |
const |
◆ CalculateCellFilledPercentage()
double tesseract::StructuredTable::CalculateCellFilledPercentage |
( |
int |
row, |
|
|
int |
column |
|
) |
| |
Definition at line 266 of file tablerecog.cpp.
274 gsearch.SetUniqueMode(
true);
275 gsearch.StartRectSearch(kCellBox);
276 double area_covered = 0;
277 ColPartition* text =
nullptr;
278 while ((text = gsearch.NextRectSearch()) !=
nullptr) {
279 if (text->IsTextType())
280 area_covered += text->bounding_box().intersection(kCellBox).area();
282 const int32_t current_area = kCellBox.area();
283 if (current_area == 0) {
286 return std::min(1.0, area_covered / current_area);
◆ CalculateMargins()
void tesseract::StructuredTable::CalculateMargins |
( |
| ) |
|
|
protected |
◆ CalculateStats()
void tesseract::StructuredTable::CalculateStats |
( |
| ) |
|
|
protected |
Definition at line 518 of file tablerecog.cpp.
519 const int kMaxCellHeight = 1000;
520 const int kMaxCellWidth = 1000;
521 STATS height_stats(0, kMaxCellHeight + 1);
522 STATS width_stats(0, kMaxCellWidth + 1);
◆ cell_count()
int tesseract::StructuredTable::cell_count |
( |
| ) |
const |
◆ ClearStructure()
void tesseract::StructuredTable::ClearStructure |
( |
| ) |
|
|
protected |
◆ column_count()
int tesseract::StructuredTable::column_count |
( |
| ) |
const |
◆ column_width()
int tesseract::StructuredTable::column_width |
( |
int |
column | ) |
const |
◆ CountFilledCells() [1/2]
int tesseract::StructuredTable::CountFilledCells |
( |
| ) |
|
◆ CountFilledCells() [2/2]
int tesseract::StructuredTable::CountFilledCells |
( |
int |
row_start, |
|
|
int |
row_end, |
|
|
int |
column_start, |
|
|
int |
column_end |
|
) |
| |
Definition at line 232 of file tablerecog.cpp.
235 ASSERT_HOST(0 <= column_start && column_start <= column_end &&
239 for (
int row = row_start; row <= row_end; ++row) {
242 for (
int col = column_start; col <= column_end; ++col) {
◆ CountFilledCellsInColumn()
int tesseract::StructuredTable::CountFilledCellsInColumn |
( |
int |
column | ) |
|
◆ CountFilledCellsInRow()
int tesseract::StructuredTable::CountFilledCellsInRow |
( |
int |
row | ) |
|
◆ CountHorizontalIntersections()
int tesseract::StructuredTable::CountHorizontalIntersections |
( |
int |
y | ) |
|
|
protected |
Definition at line 662 of file tablerecog.cpp.
668 horizontal_box.
set_top(y + kGridSize);
671 gsearch.SetUniqueMode(
true);
672 gsearch.StartRectSearch(horizontal_box);
673 ColPartition* text =
nullptr;
674 while ((text = gsearch.NextRectSearch()) !=
nullptr) {
675 if (!text->IsTextType())
678 const TBOX& box = text->bounding_box();
◆ CountPartitions()
int tesseract::StructuredTable::CountPartitions |
( |
const TBOX & |
box | ) |
|
|
protected |
Definition at line 688 of file tablerecog.cpp.
690 gsearch.SetUniqueMode(
true);
691 gsearch.StartRectSearch(box);
693 ColPartition* text =
nullptr;
694 while ((text = gsearch.NextRectSearch()) !=
nullptr) {
695 if (text->IsTextType())
◆ CountVerticalIntersections()
int tesseract::StructuredTable::CountVerticalIntersections |
( |
int |
x | ) |
|
|
protected |
Definition at line 638 of file tablerecog.cpp.
643 vertical_box.
set_left(x - kGridSize);
647 gsearch.SetUniqueMode(
true);
648 gsearch.StartRectSearch(vertical_box);
649 ColPartition* text =
nullptr;
650 while ((text = gsearch.NextRectSearch()) !=
nullptr) {
651 if (!text->IsTextType())
653 const TBOX& box = text->bounding_box();
◆ Display()
◆ DoesPartitionFit()
bool tesseract::StructuredTable::DoesPartitionFit |
( |
const ColPartition & |
part | ) |
const |
◆ FindCellSplitLocations()
Definition at line 592 of file tablerecog.cpp.
598 if (min_list.
size() == 0)
602 max_list.
get(max_list.
size() - 1));
607 int stacked_partitions = 0;
608 int last_cross_position = INT32_MAX;
612 while (min_index < min_list.
size()) {
614 if (min_list[min_index] < max_list[max_index]) {
615 ++stacked_partitions;
616 if (last_cross_position != INT32_MAX &&
617 stacked_partitions > max_merged) {
618 int mid = (last_cross_position + min_list[min_index]) / 2;
620 last_cross_position = INT32_MAX;
625 --stacked_partitions;
626 if (last_cross_position == INT32_MAX &&
627 stacked_partitions <= max_merged) {
628 last_cross_position = max_list[max_index];
◆ FindHorizontalMargin()
int tesseract::StructuredTable::FindHorizontalMargin |
( |
ColPartitionGrid * |
grid, |
|
|
int |
start_y, |
|
|
bool |
decrease |
|
) |
| const |
|
protected |
Definition at line 501 of file tablerecog.cpp.
504 gsearch.SetUniqueMode(
true);
506 ColPartition* part =
nullptr;
507 while ((part = gsearch.NextSideSearch(decrease)) !=
nullptr) {
508 if (!part->IsTextType() && !part->IsVerticalLine())
510 int distance = decrease ? border - part->bounding_box().right()
511 : part->bounding_box().left() - border;
◆ FindLinedStructure()
bool tesseract::StructuredTable::FindLinedStructure |
( |
| ) |
|
Definition at line 140 of file tablerecog.cpp.
146 box_search.SetUniqueMode(
true);
148 ColPartition* line =
nullptr;
150 while ((line = box_search.NextRectSearch()) !=
nullptr) {
151 if (line->IsHorizontalLine())
153 if (line->IsVerticalLine())
◆ FindVerticalMargin()
int tesseract::StructuredTable::FindVerticalMargin |
( |
ColPartitionGrid * |
grid, |
|
|
int |
start_x, |
|
|
bool |
decrease |
|
) |
| const |
|
protected |
Definition at line 484 of file tablerecog.cpp.
487 gsearch.SetUniqueMode(
true);
490 ColPartition* part =
nullptr;
491 while ((part = gsearch.NextVerticalSearch(decrease)) !=
nullptr) {
492 if (!part->IsTextType() && !part->IsHorizontalLine())
494 int distance = decrease ? border - part->bounding_box().top()
495 : part->bounding_box().bottom() - border;
◆ FindWhitespacedColumns()
void tesseract::StructuredTable::FindWhitespacedColumns |
( |
| ) |
|
|
protected |
Definition at line 354 of file tablerecog.cpp.
363 gsearch.SetUniqueMode(
true);
365 ColPartition* text =
nullptr;
366 while ((text = gsearch.NextRectSearch()) !=
nullptr) {
367 if (!text->IsTextType())
370 ASSERT_HOST(text->bounding_box().left() < text->bounding_box().right());
371 int spacing = static_cast<int>(text->median_width() *
373 left_sides.
push_back(text->bounding_box().left() - spacing);
374 right_sides.
push_back(text->bounding_box().right() + spacing);
377 if (left_sides.
size() == 0 || right_sides.
size() == 0)
◆ FindWhitespacedRows()
void tesseract::StructuredTable::FindWhitespacedRows |
( |
| ) |
|
|
protected |
Definition at line 399 of file tablerecog.cpp.
405 int min_bottom = INT32_MAX;
406 int max_top = INT32_MIN;
413 gsearch.SetUniqueMode(
true);
415 ColPartition* text =
nullptr;
416 while ((text = gsearch.NextRectSearch()) !=
nullptr) {
417 if (!text->IsTextType())
420 ASSERT_HOST(text->bounding_box().bottom() < text->bounding_box().top());
421 min_bottom = std::min(min_bottom, static_cast<int>(text->bounding_box().bottom()));
422 max_top = std::max(max_top, static_cast<int>(text->bounding_box().top()));
429 int spacing = static_cast<int>(text->bounding_box().height() *
431 int bottom = text->bounding_box().bottom() - spacing;
432 int top = text->bounding_box().top() + spacing;
443 if (bottom_sides.
size() == 0 || top_sides.
size() == 0)
◆ FindWhitespacedStructure()
bool tesseract::StructuredTable::FindWhitespacedStructure |
( |
| ) |
|
◆ Init()
void tesseract::StructuredTable::Init |
( |
| ) |
|
◆ is_lined()
bool tesseract::StructuredTable::is_lined |
( |
| ) |
const |
◆ median_cell_height()
int tesseract::StructuredTable::median_cell_height |
( |
| ) |
|
◆ median_cell_width()
int tesseract::StructuredTable::median_cell_width |
( |
| ) |
|
◆ row_count()
int tesseract::StructuredTable::row_count |
( |
| ) |
const |
◆ row_height()
int tesseract::StructuredTable::row_height |
( |
int |
row | ) |
const |
◆ set_bounding_box()
void tesseract::StructuredTable::set_bounding_box |
( |
const TBOX & |
box | ) |
|
◆ set_line_grid()
◆ set_max_text_height()
void tesseract::StructuredTable::set_max_text_height |
( |
int |
height | ) |
|
◆ set_text_grid()
◆ space_above()
int tesseract::StructuredTable::space_above |
( |
| ) |
const |
◆ space_below()
int tesseract::StructuredTable::space_below |
( |
| ) |
const |
◆ UpdateMargins()
◆ VerifyLinedTableCells()
bool tesseract::StructuredTable::VerifyLinedTableCells |
( |
| ) |
|
|
protected |
◆ VerifyRowFilled()
bool tesseract::StructuredTable::VerifyRowFilled |
( |
int |
row | ) |
|
◆ VerifyWhitespacedTable()
bool tesseract::StructuredTable::VerifyWhitespacedTable |
( |
| ) |
|
|
protected |
◆ bounding_box_
TBOX tesseract::StructuredTable::bounding_box_ |
|
protected |
◆ cell_x_
◆ cell_y_
◆ is_lined_
bool tesseract::StructuredTable::is_lined_ |
|
protected |
◆ line_grid_
◆ max_text_height_
int tesseract::StructuredTable::max_text_height_ |
|
protected |
◆ median_cell_height_
int tesseract::StructuredTable::median_cell_height_ |
|
protected |
◆ median_cell_width_
int tesseract::StructuredTable::median_cell_width_ |
|
protected |
◆ space_above_
int tesseract::StructuredTable::space_above_ |
|
protected |
◆ space_below_
int tesseract::StructuredTable::space_below_ |
|
protected |
◆ space_left_
int tesseract::StructuredTable::space_left_ |
|
protected |
◆ space_right_
int tesseract::StructuredTable::space_right_ |
|
protected |
◆ text_grid_
The documentation for this class was generated from the following files:
void FindWhitespacedRows()
const int kCellSplitRowThreshold
GenericVectorEqEq< int > cell_y_
int FindVerticalMargin(ColPartitionGrid *grid, int start_x, bool decrease) const
const double kHorizontalSpacing
int CountPartitions(const TBOX &box)
GridSearch< ColPartition, ColPartition_CLIST, ColPartition_C_IT > ColPartitionGridSearch
int column_width(int column) const
bool VerifyWhitespacedTable()
int CountVerticalIntersections(int x)
const double kMinFilledArea
double CalculateCellFilledPercentage(int row, int column)
void UpdateMargins(ColPartitionGrid *grid)
int row_height(int row) const
GenericVectorEqEq< int > cell_x_
UnicodeText::const_iterator::difference_type distance(const UnicodeText::const_iterator &first, const UnicodeText::const_iterator &last)
ColPartitionGrid * text_grid_
const double kVerticalSpacing
const int kCellSplitColumnThreshold
void FindWhitespacedColumns()
ColPartitionGrid * line_grid_
bool VerifyLinedTableCells()
int CountHorizontalIntersections(int y)
int FindHorizontalMargin(ColPartitionGrid *grid, int start_y, bool decrease) const
void Line(int x1, int y1, int x2, int y2)
void Rectangle(int x1, int y1, int x2, int y2)
static void FindCellSplitLocations(const GenericVector< int > &min_list, const GenericVector< int > &max_list, int max_merged, GenericVector< int > *locations)